---
title: "PSRM_Replication"
author: "Daniel Rojas"
date: "`r Sys.Date()`"
output: pdf_document
---

This document replicates the results from Resmini and Rojas, *Government Ideology and Support for Redistribution among the Wealthy*, including main results and results reported in the online supplementary information (SI). The data used to reproduce the results is available in the PSRM Dataverse.

- Software: RStudio Version 2024.09.1+394 (2024.09.1+394)

- Computer specification: MacBook Air (M1, 2020), macOS Monterey, chip Apple M1, memory 16 GB.

- Contact: danielrojaslozano@gmail.com


```{r setup, include=FALSE}

knitr::opts_chunk$set(
  warning = FALSE,
  message = FALSE
)


# Function to install or load packages
install_and_load = function(packages) {
        for (pkg in packages) {
                if (!requireNamespace(pkg, quietly = TRUE)) {
                        install.packages(pkg, dependencies = TRUE)
                }
                library(pkg, character.only = TRUE)
        }
}

# Install/load packages
install_and_load(c('patchwork',
                   'tidyverse',
                   'foreach',
                   'estimatr',
                   'texreg',
                   'kableExtra',
                   'data.table',
                   'haven'))

# load datasets
col22 = readRDS('colombia_april2022.rds') %>% 
    mutate(sample = 'Online Panel')
col22_2 = readRDS('colombia_june2022.rds')
dt18 = readRDS('lapop_col18.rds') %>% 
    mutate(municipio = as.numeric(municipio))
dt = readRDS("preferences_lapop_data.RDS") %>% 
    mutate(municipio = as.numeric(municipio))
ecp21 = readRDS('ecp_subsample2021.rds') %>% 
    select(female,age_dummy,married,college_dummy,catholic,right_dummy) %>% 
    mutate(sample = 'National Sample')
col22_subset = readRDS('colombia_april2022.rds') %>% 
    filter(education == 6 |education == 7)
col22_2_subset = readRDS('colombia_june2022.rds') %>% 
    filter(education == 6 |education == 7)


# merge col22 & ecp21
dt_merged = merge(ecp21, col22, all = TRUE) %>% 
    mutate(female = as.numeric(female))

## Merge col22 & col22_2
dt1 = col22 %>% 
    select(female, age, education, race, marriage_new, religion_new, occup, 
           ideology, vote_int_descriptive2, ideology_r_mean, ideology_clean,
           l_r_vote, r_l_ideology, ideology_3) %>% 
    mutate(sample = 'Sample 1')

dt2 = col22_2 %>% 
    select(rodolf_id, female, age, education, race, marriage_new, religion_new, 
           occup, ideology, vote_int_descriptive2, ideology_r_mean, ideology_clean,
           l_r_vote, r_l_ideology, ideology_3) %>% 
    mutate(sample = 'Sample 2')

dt_pooled = merge(dt1, dt2, all = TRUE)


# Figure settings
pd = position_dodge(0.2) 


```

# Manuscript - Figures 

## Figure 1
```{r fig.height=4}
dt[, pdt_ideology_herre := case_when(country=='Argentina'~'Right',
                                     country=='Bolivia'~'Left',
                                     country=='Brazil'~'Right',
                                     country=='Chile'~'Right', 
                                     country=='Colombia'~'Right',
                                     country=='Costa Rica'~'Left',
                                     country=='Ecuador'~'Left',
                                     country=='El Salvador'~'Left', 
                                     country=='Guatemala'~'Right',
                                     country=='Honduras'~'Right',
                                     country=='Mexico'~'Left',
                                     country=='Paraguay'~'Right',
                                     country=='Peru'~'Right',
                                     country=='Uruguay'~'Left',
                                     TRUE ~ NA_character_) %>% as.factor(.)]


dt[, right_gov_dummy := case_when(pdt_ideology_herre=='Right'~1,
                                  pdt_ideology_herre=='Left'~0,
                                  TRUE ~ NA_real_) %>% as.factor()]



# Figure 1 ----------------------------------------------------------------

out = lm_robust(progressive_redist ~ consumpd*right_gov_dummy +
                        size_population+urban+big_city+women+age+education+
                        catholic+sec_perception_neighborhood+religiosity+
                        employed+married+color+news_cons_d+victim_del+
                        stable_income+trust_congress+trust_parties+
                        trust_president+gov_assistance+stable_cnt_econ+ 
                        stable_ind_econ+voted_pdt, 
                data = dt, 
                clusters = as_factor(municipio), fixed_effects = country) 

# without country FE
out2 = lm_robust(progressive_redist ~ consumpd*right_gov_dummy +
                         size_population+urban+big_city+women+age+education+
                         catholic+sec_perception_neighborhood+religiosity+
                         employed+married+color+news_cons_d+victim_del+
                         stable_income+trust_congress+trust_parties+
                         trust_president+gov_assistance+stable_cnt_econ+ 
                         stable_ind_econ+voted_pdt, 
                 data = dt, 
                 clusters = as_factor(municipio)) 

out_dt = data.frame(estimate = c(out$coefficients[1:9], out$coefficients[33:41]),
                    lower = c(out$conf.low[1:9], out$conf.low[33:41]),
                    upper = c(out$conf.high[1:9], out$conf.high[33:41]),
                    gov = c(rep('Left', 9), rep('Right', 9)),
                    decile = rep(factor(c('D2','D3','D4','D5','D6','D7','D8','D9','D10'),
                                        levels = c('D2','D3','D4','D5',
                                                   'D6','D7','D8','D9','D10')),
                                 2))


ggplot(out_dt, aes(x=decile, y=estimate, color=gov)) +
        geom_point(position = position_dodge(w=0.3)) +
        geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, 
                      position = position_dodge(w=0.3)) +
        geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
        ggtitle('Support for Redistribution among the Wealthy in Latin America') +
        xlab("") + ylab("") + 
        scale_y_continuous(limits = c(-.2,.2)) +
        theme(legend.position = "bottom")+ theme_bw() +
        coord_flip() + 
        theme(legend.position = "bottom") +
        scale_color_manual(values = c('#999999','#333333'),
                           name="Government", labels=c("Left","Right"))

```

## Figure 2

```{r fig.height=3}

# set up formula root:
f = list(tax_dummy~t_tax,
         subsidy_dummy~t_subsidy,
         uncert_scale~t_uncert,
         effectiveness_dummy~t_effectiveness,
         stability_dummy~t_stability,
         police_dummy~t_police,
         visa_dummy~t_visa)

## Regressions
out_s1 = list()
out_s1_1 = list()

covariates = c('+age','female','capital','white','catholic','married',
               'university_degree','employed','exp_crime','guerrilla_threat',
               'migration','trust_institutions','ideology_r_mean2',
               'resent','vote_fico')

# function to run regressions
for(i in 1:length(f)){
    out_s1[[i]] = lm_robust(as.formula(paste(f[i], 
                                             paste(covariates, collapse = '+'))), 
                            data = col22)
    out_s1_1[[i]] = lm_robust(f[[i]], data = col22)
}

outcomes_s1 = data.frame(outcome = c('Progressive Taxation',
                                     'Subsidies',
                                     'Uncertainty',
                                     'Efficiency',
                                     'Stability',
                                     'Police',
                                     'Visa',
                                     'Progressive Taxation',
                                     'Subsidies',
                                     'Uncertainty',
                                     'Efficiency',
                                     'Stability',
                                     'Police',
                                     'Visa'),
                         ATE = c(rep('ATE', length(f)*2)),
                         estimate = c(foreach(i=1:length(f)) %do% 
                                          out_s1[[i]]$coefficients[2] %>% 
                             unlist(), foreach(i=1:length(f)) %do% 
                                 out_s1_1[[i]]$coefficients[2] %>% 
                                 unlist()),
                         lower = c(foreach(i=1:length(f)) %do% 
                                       out_s1[[i]]$conf.low[2] %>% 
                             unlist(), foreach(i=1:length(f)) %do% 
                                 out_s1_1[[i]]$conf.low[2] %>% 
                                 unlist()),
                         upper = c(foreach(i=1:length(f)) %do% 
                                       out_s1[[i]]$conf.high[2] %>% 
                             unlist(), foreach(i=1:length(f)) %do% 
                                 out_s1_1[[i]]$conf.high[2] %>% 
                                 unlist()),
                         group = c('Preferences','Preferences',
                                   'Explanations','Explanations','Explanations',
                                   'Placebos','Placebos'),
                         covariates = c(rep(1, length(f)),
                                        rep(0, length(f))))


outcomes_s1 %>% 
    filter(group=='Preferences') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('Redistributive Preferences - Study 1') +
    xlab('') +
    ylab('Change in Pr(Support)') +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes"),
                       guide = guide_legend(reverse = TRUE)) +
    facet_wrap(~outcome)

```

## Figure 3

```{r fig.height=3}

## Regressions
out_s2 = list()
out_s2_1 = list()
covariates2 = c('+age','female','capital','white','catholic','married',
                'university_degree','employed','exp_crime','guerrilla_threat',
                'migration','trust_institutions','ideology_r_mean2',
                'resent','rodolf_right','vote_hernandez')


for(i in 1:length(f)){
    out_s2[[i]] = lm_robust(as.formula(paste(f[i], 
                                             paste(covariates2, collapse = '+'))), 
                            data = col22_2)
    out_s2_1[[i]] = lm_robust(f[[i]], data = col22_2)
}

outcomes_s2 = data.frame(outcome = c('Progressive Taxation',
                                     'Subsidies',
                                     'Uncertainty',
                                     'Efficiency',
                                     'Stability',
                                     'Police',
                                     'Visa',
                                     'Progressive Taxation',
                                     'Subsidies',
                                     'Uncertainty',
                                     'Efficiency',
                                     'Stability',
                                     'Police',
                                     'Visa'),
                         ATE = c(rep('ATE', length(f)*2)),
                         estimate = c(foreach(i=1:length(f)) %do% 
                                          out_s2[[i]]$coefficients[2] %>% 
                             unlist(), foreach(i=1:length(f)) %do% 
                                 out_s2_1[[i]]$coefficients[2] %>% 
                                 unlist()),
                         lower = c(foreach(i=1:length(f)) %do% 
                                       out_s2[[i]]$conf.low[2] %>% 
                             unlist(), foreach(i=1:length(f)) %do% 
                                 out_s2_1[[i]]$conf.low[2] %>% 
                                 unlist()),
                         upper = c(foreach(i=1:length(f)) %do% 
                                       out_s2[[i]]$conf.high[2] %>% 
                             unlist(), foreach(i=1:length(f)) %do% 
                                 out_s2_1[[i]]$conf.high[2] %>% 
                                 unlist()),
                         group = c('Preferences','Preferences',
                                   'Explanations','Explanations','Explanations',
                                   'Placebos','Placebos'),
                         covariates = c(rep(1, length(f)),
                                        rep(0, length(f))))

outcomes_s2 %>% 
    filter(group=='Preferences') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('Redistributive Preferences - Study 2') +
    xlab('') +
    ylab('Change in Pr(Support)') +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes"),
                       guide = guide_legend(reverse = TRUE)) +
    facet_wrap(~outcome)

```

## Figure 4

```{r fig.height=3}

## Merge dt 1 & 2
dt1 = col22 %>% 
    select(female, age, education, race, marriage_new, religion_new, occup, 
           ideology, vote_int_descriptive2, ideology_r_mean, ideology_clean,
           l_r_vote, r_l_ideology, ideology_3) %>% 
    mutate(sample = 'Sample 1')

dt2 = col22_2 %>% 
    select(rodolf_id, female, age, education, race, marriage_new, religion_new, 
           occup, ideology, vote_int_descriptive2, ideology_r_mean, ideology_clean,
           l_r_vote, r_l_ideology, ideology_3) %>% 
    mutate(sample = 'Sample 2')


dt_pooled = merge(dt1, dt2, all = TRUE)

dt_pooled %>% 
    filter(!is.na(ideology_r_mean)) %>% 
    ggplot(., aes(x=as.factor(ideology_r_mean))) + 
    geom_bar(aes(y = ..prop.., group=sample), position = "dodge") +
    labs(subtitle = "Ideological Distribution of Respondents (Excluding Centrists)") +
    scale_y_continuous(limits = c(0,.8)) +
    xlab("") +
    ylab("") +
    facet_wrap(~sample, 
               labeller = labeller(sample = c('Sample 1'='Study 1', 
                                              'Sample 2'='Study 2'))) +
    scale_x_discrete(labels = c('Left','Right')) + 
    theme(panel.background = element_blank(),
          panel.border = element_rect(colour = "gray", fill=NA, size=.8))  

```


## Figure 5

```{r}
# Survey 1 (without controls)

# Progressive taxes
tax1.0 = lm_robust(tax_dummy ~ t_tax,
                   data = col22,
                   subset = ideology_r_mean == 0) 


tax1.1 = lm_robust(tax_dummy ~ t_tax,
                   data = col22,
                   subset = ideology_r_mean == 1) 

beta = tax1.0$coefficients[2]
lb = tax1.0$conf.low[2]
ub = tax1.0$conf.high[2]
dt_tax1.0 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, Rightwing = 'No')

beta = tax1.1$coefficients[2]
lb = tax1.1$conf.low[2]
ub = tax1.1$conf.high[2]
dt_tax1.1 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, Rightwing = 'Yes')


# Subsidies
Subsidies1.0 = lm_robust(subsidy_dummy ~ t_subsidy,
                         data = col22,
                         subset = ideology_r_mean == 0) 

Subsidies1.1 = lm_robust(subsidy_dummy ~ t_subsidy,
                         data = col22,
                         subset = ideology_r_mean == 1) 

beta = Subsidies1.0$coefficients[2]
lb = Subsidies1.0$conf.low[2]
ub = Subsidies1.0$conf.high[2]
dt_subsidy1.0 = data.frame(variable = 'Subsidies', beta, lb, ub, Rightwing = 'No')

beta = Subsidies1.1$coefficients[2]
lb = Subsidies1.1$conf.low[2]
ub = Subsidies1.1$conf.high[2]
dt_subsidy1.1 = data.frame(variable = 'Subsidies', beta, lb, ub, Rightwing = 'Yes')

dt1 = rbind(dt_tax1.0, dt_tax1.1, 
            dt_subsidy1.0, dt_subsidy1.1) %>% 
    mutate(variable = factor(variable, levels = c('Progressive Taxation',
                                                  'Subsidies')),
           ATE = rep('ATE', length(variable)))

# Plot
## Heterogeneous Preferences Among The Wealthy
preferences1 = ggplot(dt1, 
                      aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                          group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 1') +
    xlab('') +
    ylab('') + 
    scale_y_continuous(limits = c(-.8,.8)) +
    coord_flip() + 
    theme_bw() +
    theme(axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'none') +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) + 
    facet_wrap(~variable) +
    guides("none") 



# Mechanisms (uncertainty is reported in regression tables)
## Effectiveness

eff1.0 = lm_robust(effectiveness_dummy ~ t_effectiveness,
                   data = col22,
                   subset = ideology_r_mean == 0) 

eff1.1 = lm_robust(effectiveness_dummy ~ t_effectiveness,
                   data = col22,
                   subset = ideology_r_mean == 1) 

beta = eff1.0$coefficients[2]
lb = eff1.0$conf.low[2]
ub = eff1.0$conf.high[2]
dt_eff1.0 = data.frame(variable = 'Efficiency', beta, lb, ub, Rightwing = 'No')

beta = eff1.1$coefficients[2]
lb = eff1.1$conf.low[2]
ub = eff1.1$conf.high[2]
dt_eff1.1 = data.frame(variable = 'Efficiency', beta, lb, ub, Rightwing = 'Yes')

## Economic Instability
stability1.0 = lm_robust(stability_dummy ~ t_stability,
                         data = col22,
                         subset = ideology_r_mean == 0)

stability1.1 = lm_robust(stability_dummy ~ t_stability,
                         data = col22,
                         subset = ideology_r_mean == 1)

beta = stability1.0$coefficients[2]
lb = stability1.0$conf.low[2]
ub = stability1.0$conf.high[2]
dt_stability1.0 = data.frame(variable = 'Instability', beta, lb, ub, Rightwing = 'No')

beta = stability1.1$coefficients[2]
lb = stability1.1$conf.low[2]
ub = stability1.1$conf.high[2]
dt_stability1.1 = data.frame(variable = 'Instability', beta, lb, ub, Rightwing = 'Yes')

dt1_mechanisms = rbind(dt_eff1.0, dt_eff1.1,
                       dt_stability1.0, dt_stability1.1) %>% 
    mutate(ATE = rep('ATE', length(variable)))

## Heterogeneous Expectations Among The Wealthy
mechanisms1 = ggplot(dt1_mechanisms, 
                     aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                         group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 1') +
    xlab('') +
    ylab('') + 
    scale_y_continuous(limits = c(-1,1)) +
    coord_flip() +
    theme_bw() +
    theme(axis.text.x = element_blank(), 
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'none') +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable) +
    guides("none")


# Survey 2 (without controls)

# Progressive taxes
tax2.0 = lm_robust(tax_dummy ~ t_tax,
                   data = col22_2,
                   subset = ideology_r_mean == 0) 

tax2.1 = lm_robust(tax_dummy ~ t_tax,
                   data = col22_2,
                   subset = ideology_r_mean == 1) 

beta = tax2.0$coefficients[2]
lb = tax2.0$conf.low[2]
ub = tax2.0$conf.high[2]
dt_tax2.0 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, Rightwing = 'No')

beta = tax2.1$coefficients[2]
lb = tax2.1$conf.low[2]
ub = tax2.1$conf.high[2]
dt_tax2.1 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, Rightwing = 'Yes')


# Subsidies
Subsidies2.0 = lm_robust(subsidy_dummy ~ t_subsidy,
                         data = col22_2,
                         subset = ideology_r_mean == 0) 

Subsidies2.1 = lm_robust(subsidy_dummy ~ t_subsidy,
                         data = col22_2,
                         subset = ideology_r_mean == 1) 

beta = Subsidies2.0$coefficients[2]
lb = Subsidies2.0$conf.low[2]
ub = Subsidies2.0$conf.high[2]
dt_subsidy2.0 = data.frame(variable = 'Subsidies', beta, lb, ub, Rightwing = 'No')

beta = Subsidies2.1$coefficients[2]
lb = Subsidies2.1$conf.low[2]
ub = Subsidies2.1$conf.high[2]
dt_subsidy2.1 = data.frame(variable = 'Subsidies', beta, lb, ub, Rightwing = 'Yes')

dt2 = rbind(dt_tax2.0, dt_tax2.1, 
            dt_subsidy2.0, dt_subsidy2.1) %>% 
    mutate(variable = factor(variable, levels = c('Progressive Taxation',
                                                  'Subsidies')),
           ATE = rep('ATE', length(variable)))

# Plot
preferences2 = ggplot(dt2, 
                      aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                          group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 2') +
    xlab('') +
    ylab('Change in Pr(Support)') + 
    scale_y_continuous(limits = c(-.8,.8)) +
    coord_flip() +
    theme_bw() + 
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank(),
          legend.position = 'bottom') + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable)



# Mechanisms
## Effectiveness
eff2.0 = lm_robust(effectiveness_dummy ~ t_effectiveness,
                   data = col22_2,
                   subset = ideology_r_mean == 0) 

eff2.1 = lm_robust(effectiveness_dummy ~ t_effectiveness,
                   data = col22_2,
                   subset = ideology_r_mean == 1) 

beta = eff2.0$coefficients[2]
lb = eff2.0$conf.low[2]
ub = eff2.0$conf.high[2]
dt_eff2.0 = data.frame(variable = 'Efficiency', beta, lb, ub, Rightwing = 'No')

beta = eff2.1$coefficients[2]
lb = eff2.1$conf.low[2]
ub = eff2.1$conf.high[2]
dt_eff2.1 = data.frame(variable = 'Efficiency', beta, lb, ub, Rightwing = 'Yes')

## Economic Instability
stability2.0 = lm_robust(stability_dummy ~ t_stability,
                         data = col22_2,
                         subset = ideology_r_mean == 0)

stability2.1 = lm_robust(stability_dummy ~ t_stability,
                         data = col22_2,
                         subset = ideology_r_mean == 1)

beta = stability2.0$coefficients[2]
lb = stability2.0$conf.low[2]
ub = stability2.0$conf.high[2]
dt_stability2.0 = data.frame(variable = 'Instability', beta, lb, ub, Rightwing = 'No')

beta = stability2.1$coefficients[2]
lb = stability2.1$conf.low[2]
ub = stability2.1$conf.high[2]
dt_stability2.1 = data.frame(variable = 'Instability', beta, lb, ub, Rightwing = 'Yes')

dt2_mechanisms = rbind(dt_eff2.0, dt_eff2.1,
                       dt_stability2.0, dt_stability2.1) %>% 
    mutate(ATE = rep('ATE', length(variable)))

# plots
mechanisms2 = ggplot(dt2_mechanisms, 
                     aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                         group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 2') +
    xlab('') +
    ylab('Change in Pr(Expectation)') + 
    scale_y_continuous(limits = c(-1,1)) +
    coord_flip() +
    theme_bw() + 
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank(),
          legend.position = 'bottom') + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable)


preferences1 + preferences2 + plot_layout(ncol = 1)

```

## Figure 6

```{r}

mechanisms1 + mechanisms2 + plot_layout(ncol = 1)

```


# Manuscript - Tables  

## Table 1

```{r results='asis'}

# harmonizing coefficients
out_s1_1[[3]]$term[2] = 't1'
out_s1_1[[4]]$term[2] = 't1'
out_s1_1[[5]]$term[2] = 't1'

out_s1[[3]]$term[2] = 't1'
out_s1[[4]]$term[2] = 't1'
out_s1[[5]]$term[2] = 't1'



texreg(list(out_s1_1[[3]], out_s1[[3]], 
            out_s1_1[[4]], out_s1[[4]], 
            out_s1_1[[5]], out_s1[[5]]),
       caption = "Testing Theoretical Explanations - Study 1",
       #file = '../output/tables/Table 1.tex',
       label = "table:mechanisms1",
       use.packages = FALSE,
       custom.header = list('Uncertainty'=1:2,
                            'Efficiency'=3:4,
                            'Instability'=5:6),
       custom.model.names = c('1','2','3','4','5','6'),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate'),
       float.pos = "h",
       digits = 3,
       caption.above = TRUE,
       #custom.coef.names = mechanisms1_controls,
       include.rsquared = F, include.adjrs = F, include.groups = T,
       include.ci = F, include.nclust=F,
       custom.gof.rows = list("Covariate Adjustment"=c("No","Yes",
                                                       "No","Yes",
                                                       "No","Yes")),
       #reorder.gof = c(1,3,4,2,5,6),
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)

```


## Table 2

```{r results='asis'}

# harmonizing coefficients
out_s2_1[[3]]$term[2] = 't1'
out_s2_1[[4]]$term[2] = 't1'
out_s2_1[[5]]$term[2] = 't1'

out_s2[[3]]$term[2] = 't1'
out_s2[[4]]$term[2] = 't1'
out_s2[[5]]$term[2] = 't1'

# regression table
texreg(list(out_s2_1[[3]], out_s2[[3]], 
            out_s2_1[[4]], out_s2[[4]], 
            out_s2_1[[5]], out_s2[[5]]),
       caption = "Testing Theoretical Explanations - Study 2",
        use.packages = FALSE,
       label = "table:mechanisms2",
       custom.header = list('Uncertainty'=1:2,
                            'Efficiency'=3:4,
                            'Instability'=5:6),
       custom.model.names = c('1','2','3','4','5','6'),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate'),
       float.pos = "h",
       digits = 3,
       caption.above = TRUE,
       #custom.coef.names = mechanisms1_controls,
       include.rsquared = F, include.adjrs = F, include.groups = T,
       include.ci = F, include.nclust=F,
       custom.gof.rows = list("Covariate Adjustment"=c("No","Yes",
                                                       "No","Yes",
                                                       "No","Yes")),
       #reorder.gof = c(1,3,4,2,5,6),
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)


```





# Online SI - Figures

## Figure S1

```{r}
# generate plots
sex = ggplot(dt_pooled, aes(x=female, fill = sample)) + 
    geom_bar(aes(y = ..prop.., group = sample), position = "dodge") +
    labs(subtitle = "Sex") +
    xlab("") +
    scale_y_continuous(limits = c(0,1)) +
    scale_x_discrete(labels = c('Male','Female')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")


age = ggplot(dt_pooled, aes(x=age, fill = sample)) + 
    geom_bar(aes(y = ..prop.., group= sample), position = "dodge") +
    labs(subtitle = "Age") +
    xlab("") +
    scale_y_continuous(limits = c(0,1)) +
    scale_x_discrete(labels = c("18-24", 
                                "25-34",
                                "35-44",
                                "45-54",
                                "55+")) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")

education = ggplot(dt_pooled, aes(x=education, fill = sample)) + 
    geom_bar(aes(y = ..prop.., group=sample), position = "dodge") +
    labs(subtitle = "Education") +
    xlab("") +
    scale_y_continuous(limits = c(0,1)) +
    scale_x_discrete(labels = c('Primary','High Sch.','University','Technical',
                                'Master','PhD')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_text(angle = 45, hjust = 1)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")

race = dt_pooled %>% 
    filter(race=='1'|race=='2'|race=='3'|race=='4'|race=='5'|race=='6') %>% 
    ggplot(., aes(x=race, fill = sample)) + 
    geom_bar(aes(y = ..prop.., group=sample), position = "dodge") +
    labs(subtitle = "Race") +
    xlab("") +
    scale_y_continuous(limits = c(0,1)) +
    scale_x_discrete(labels = c('White','Mestizo','Indigenous','Afro','Mulato','Other')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_text(angle = 45, hjust = 1)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")

marriage = ggplot(dt_pooled, aes(x=marriage_new, fill = sample)) + 
    geom_bar(aes(y = ..prop.., group=sample), position = "dodge") +
    labs(subtitle = "Marriage") +
    xlab("") +
    scale_y_continuous(limits = c(0,1)) +
    scale_x_discrete(labels = c('Single','Married','Civil union','Divorced','Widow')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_text(angle = 45, hjust = 1)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")

religion = ggplot(dt_pooled, aes(x=religion_new, fill = sample)) + 
    geom_bar(aes(y = ..prop.., group=sample), position = "dodge") +
    labs(subtitle = "Religion") +
    scale_y_continuous(limits = c(0,1)) +
    xlab("") +
    scale_x_discrete(labels = c('Catholic','Evangelical','Atheist/Agnostic','Other')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_text(angle = 45, hjust = 1)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")

occupation = ggplot(dt_pooled, aes(x=occup, fill = sample)) + 
    geom_bar(aes(y = ..prop.., group=sample), position = "dodge") +
    labs(subtitle = "Occupation") +
    scale_y_continuous(limits = c(0,1)) +
    xlab("") +
    scale_x_discrete(labels = c('Business owner','Salaried employee',
                                'Self-employed','Retired','Student',
                                'Unemployed','Other')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_text(angle = 45, hjust = 1)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")

ideology = dt_pooled %>% 
    filter(ideology %in% 1:5) %>% 
    ggplot(., aes(x=as.factor(ideology), fill = sample)) + 
    geom_bar(aes(y = ..prop.., group=sample), position = "dodge") +
    labs(subtitle = "Political Ideology") +
    scale_y_continuous(limits = c(0,1)) +
    xlab("") +
    scale_x_discrete(labels = c('Left','',
                                '','','Right',
                                'NA')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")


vote_int = dt_pooled %>% 
    filter(vote_int_descriptive2!='4') %>% 
    ggplot(., aes(x=vote_int_descriptive2, fill = sample)) + 
    geom_bar(aes(y = ..prop.., group=sample), position = "dodge") +
    labs(subtitle = "Vote Intention") +
    scale_y_continuous(limits = c(0,1)) +
    xlab("") +
    scale_x_discrete(labels = c('Petro','Gutiérrez',
                                'Hernández')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8)) +
    scale_fill_manual(values = c("#999999","#333333"), name="")

```

```{r fig.height=12, fig.width=9}
# Create plot
sex + age + education + race + marriage +  religion + occupation + ideology + vote_int +
    plot_layout(ncol = 2, guides = 'collect')

```


## Figure S2

```{r fig.height=3}
## Hernandez ideological placement
ggplot(col22_2, aes(x=as.factor(rodolf_id))) + 
    geom_bar(aes(y = ..prop.., group=1), position = "dodge") +
    ggtitle("Ideological Placement - Hernández") +
    scale_y_continuous(limits = c(0,1)) +
    xlab("") +
    scale_x_discrete(labels = c('Left','',
                                '','','Right',
                                'NA')) + 
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8))
```

## Figure S3

```{r}
# Create plots to compare data
female = dt_merged %>% 
    group_by(sample) %>% 
    summarise(mean_female = mean(female, na.rm = T),
              se_female = sd(female, na.rm = T)/sqrt(length(sample))) %>% 
    ggplot(., aes(x = sample, y = mean_female, fill = sample)) +
    geom_bar(stat = 'identity') + 
    geom_errorbar(aes(x = sample,
                      ymin = mean_female - 1.96*se_female,
                      ymax = mean_female + 1.96*se_female),
                  width = 0.2) + 
    scale_y_continuous(limits = c(0,1),
                       breaks = c(0,.2,.5,.8,1)) +
    labs(subtitle = 'Sex = Female') +
    xlab("") +
    ylab("Proportion") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank(),
        legend.position = c(0.4, 0.9),  # Adjust x and y values as needed
        legend.background = element_rect(fill = NA, color = NA),
        legend.key = element_blank()) +
    scale_fill_manual(values = c("#999999","#333333"), name="")



age = dt_merged %>% 
    group_by(sample) %>% 
    summarise(mean_age = mean(age_dummy, na.rm = T),
              se_age = sd(age_dummy, na.rm = T)/sqrt(length(sample))) %>% 
    ggplot(., aes(x = sample, y = mean_age, fill = sample)) +
    geom_bar(stat = 'identity') + 
    geom_errorbar(aes(x = sample,
                      ymin = mean_age - 1.96*se_age,
                      ymax = mean_age + 1.96*se_age),
                  width = 0.2) + 
    scale_y_continuous(limits = c(0,1),
                       breaks = c(0,.2,.5,.8,1)) +
    labs(subtitle = 'Age = 55 or older') +
    xlab("") +
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
    scale_fill_manual(values = c("#999999","#333333"), name="") +
    guides(fill = "none")  # Remove legend


married = dt_merged %>% 
    group_by(sample) %>% 
    summarise(mean_married = mean(married, na.rm = T),
              se_married = sd(married, na.rm = T)/sqrt(length(sample))) %>% 
    ggplot(., aes(x = sample, y = mean_married, fill = sample)) +
    geom_bar(stat = 'identity') + 
    geom_errorbar(aes(x = sample,
                      ymin = mean_married - 1.96*se_married,
                      ymax = mean_married + 1.96*se_married),
                  width = 0.2) + 
    scale_y_continuous(limits = c(0,1),
                       breaks = c(0,.2,.5,.8,1)) +
    labs(subtitle = 'Marital status = Married') +
    xlab("") +
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
    scale_fill_manual(values = c("#999999","#333333"), name="") +
    guides(fill = "none")  # Remove legend


college = dt_merged %>% 
    group_by(sample) %>% 
    summarise(mean_college = mean(college_dummy, na.rm = T),
              se_college = sd(college_dummy, na.rm = T)/sqrt(length(sample))) %>% 
    ggplot(., aes(x = sample, y = mean_college, fill = sample)) +
    geom_bar(stat = 'identity') + 
    geom_errorbar(aes(x = sample,
                      ymin = mean_college - 1.96*se_college,
                      ymax = mean_college + 1.96*se_college),
                  width = 0.2) + 
    scale_y_continuous(limits = c(0,1),
                       breaks = c(0,.2,.5,.8,1)) +
    labs(subtitle = 'Education = College degree') +
    xlab("") +
    ylab("Proportion") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
    scale_fill_manual(values = c("#999999","#333333"), name="") +
    guides(fill = "none")  # Remove legend

catholic = dt_merged %>% 
    group_by(sample) %>% 
    summarise(mean_cath = mean(catholic, na.rm = T),
              se_cath = sd(catholic, na.rm = T)/sqrt(length(sample))) %>% 
    ggplot(., aes(x = sample, y = mean_cath, fill = sample)) +
    geom_bar(stat = 'identity') + 
    geom_errorbar(aes(x = sample,
                      ymin = mean_cath - 1.96*se_cath,
                      ymax = mean_cath + 1.96*se_cath),
                  width = 0.2) + 
    scale_y_continuous(limits = c(0,1),
                       breaks = c(0,.2,.5,.8,1)) +
    labs(subtitle = 'Religion = Catholic') +
    xlab("") +
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
    scale_fill_manual(values = c("#999999","#333333"), name="") +    
    guides(fill = "none")  # Remove legend

right_wing = dt_merged %>% 
    group_by(sample) %>% 
    summarise(mean_right = mean(right_dummy, na.rm = T),
              se_right = sd(right_dummy, na.rm = T)/sqrt(length(sample))) %>% 
    ggplot(., aes(x = sample, y = mean_right, fill = sample)) +
    geom_bar(stat = 'identity') + 
    geom_errorbar(aes(x = sample,
                      ymin = mean_right - 1.96*se_right,
                      ymax = mean_right + 1.96*se_right),
                  width = 0.2) + 
    scale_y_continuous(limits = c(0,1)) +
    labs(subtitle = 'Ideology = Right-wing') +
    xlab("") +
    ylab("") +
    theme(
        panel.background = element_blank(),
        panel.border = element_rect(colour = "gray", fill=NA, size=.8),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
    scale_fill_manual(values = c("#999999","#333333"), name="") +
    guides(fill = "none")  # Remove legend

```


```{r}
# Merge plots
female + age + married + college + catholic + right_wing + 
    plot_layout(ncol = 3)

```

## Figure S4

```{r }
f_scale = list(tax~t_tax,
               subsidy~t_subsidy,
               uncert~t_uncert,
               effectiveness~t_effectiveness,
               stability~t_stability,
               police~t_police,
               visa~t_visa)
out_s1_c = list()
out_s1_1_c = list()

for(i in 1:length(f_scale)){
    out_s1_c[[i]] = lm_robust(as.formula(paste(f_scale[i], 
                                               paste(covariates, collapse = '+'))),
                              data = col22, clusters = ticket_id)
    out_s1_1_c[[i]] = lm_robust(f_scale[[i]], data = col22, clusters = ticket_id)
}

outcomes_s1_c = data.frame(outcome = c('Progressive Taxation',
                                       'Subsidies',
                                       'Uncertainty',
                                       'Efficiency',
                                       'Instability',
                                       'Police',
                                       'Visa',
                                       'Progressive Taxation',
                                       'Subsidies',
                                       'Uncertainty',
                                       'Efficiency',
                                       'Instability',
                                       'Police',
                                       'Visa'),
                           ATE = c(rep('ATE', length(f)*2)),
                           estimate = c(foreach(i=1:length(f_scale)) %do% 
                                            out_s1_c[[i]]$coefficients[2] %>% 
                               unlist(), foreach(i=1:length(f_scale)) %do% 
                                   out_s1_1_c[[i]]$coefficients[2] %>% 
                                   unlist()),
                           lower = c(foreach(i=1:length(f_scale)) %do% 
                                         out_s1_c[[i]]$conf.low[2] %>% 
                               unlist(), foreach(i=1:length(f_scale)) %do% 
                                   out_s1_1_c[[i]]$conf.low[2] %>% 
                                   unlist()),
                           upper = c(foreach(i=1:length(f_scale)) %do% 
                                         out_s1_c[[i]]$conf.high[2] %>% 
                               unlist(), foreach(i=1:length(f_scale)) %do% 
                                   out_s1_1_c[[i]]$conf.high[2] %>% 
                                   unlist()),
                           group = c('Preferences','Preferences',
                                     'Explanations','Explanations','Explanations',
                                     'Placebos','Placebos'),
                           covariates = c(rep(1, length(f_scale)),
                                          rep(0, length(f_scale))))


```

```{r fig.width=8, fig.height=4}

a=outcomes_s1_c %>% 
    filter(group=='Preferences') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('DVs in 5-point Scale') +
    xlab('') +
    ylab('Estimate') +
    theme_bw() + 
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes")) +
    facet_wrap(~outcome)

b=outcomes_s1_c %>% 
    filter(outcome=='Efficiency' | outcome=='Instability') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('DVs in 3-point Scale') +
    xlab('') +
    ylab('Estimate') +
    theme_bw() + 
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes")) +
    facet_wrap(~outcome)


c=outcomes_s1_c %>% 
    filter(outcome=='Uncertainty') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('DV in 20-point Scale') +
    xlab('') +
    ylab('Estimate') +
    theme_bw() + 
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes")) +
    facet_wrap(~outcome)


a+b+c + plot_layout(ncol = 2, guides = "collect")


```


## Figure S5

```{r}
out_s2_c = list()
out_s2_1_c = list()

for(i in 1:length(f_scale)){
    out_s2_c[[i]] = lm_robust(as.formula(paste(f_scale[i], 
                                               paste(covariates2, collapse = '+'))),
                              data = col22_2, clusters = ticket_id)
    out_s2_1_c[[i]] = lm_robust(f_scale[[i]], data = col22_2, clusters = ticket_id)
}

outcomes_s2_c = data.frame(outcome = c('Progressive Taxation',
                                       'Subsidies',
                                       'Uncertainty',
                                       'Efficiency',
                                       'Instability',
                                       'Police',
                                       'Visa',
                                       'Progressive Taxation',
                                       'Subsidies',
                                       'Uncertainty',
                                       'Efficiency',
                                       'Instability',
                                       'Police',
                                       'Visa'),
                           ATE = c(rep('ATE', length(f)*2)),
                           estimate = c(foreach(i=1:length(f_scale)) %do% 
                                            out_s2_c[[i]]$coefficients[2] %>% 
                                            unlist(), foreach(i=1:length(f_scale)) %do% 
                                            out_s2_1_c[[i]]$coefficients[2] %>% 
                                            unlist()),
                           lower = c(foreach(i=1:length(f_scale)) %do% 
                                         out_s2_c[[i]]$conf.low[2] %>% 
                                         unlist(),foreach(i=1:length(f_scale)) %do% 
                                         out_s2_1_c[[i]]$conf.low[2] %>% 
                                         unlist()),
                           upper = c(foreach(i=1:length(f_scale)) %do% 
                                         out_s2_c[[i]]$conf.high[2] %>% 
                                         unlist(), foreach(i=1:length(f_scale)) %do% 
                                         out_s2_1_c[[i]]$conf.high[2] %>% 
                                         unlist()),
                           group = c('Preferences','Preferences',
                                     'Explanations','Explanations','Explanations',
                                     'Placebos','Placebos'),
                           covariates = c(rep(1, length(f_scale)),
                                          rep(0, length(f_scale))))



```


```{r fig.width=8, fig.height=4}
a=outcomes_s2_c %>% 
    filter(group=='Preferences') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('DVs in 5-point Scale') +
    xlab('') +
    ylab('Estimate') +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes")) +
    facet_wrap(~outcome)

b=outcomes_s2_c %>% 
    filter(outcome=='Efficiency' | outcome=='Instability') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('DVs in 3-point Scale') +
    xlab('') +
    ylab('Estimate') +
    theme_bw() + 
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes")) +
    facet_wrap(~outcome)


c=outcomes_s2_c %>% 
    filter(outcome=='Uncertainty') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('DV in 20-point Scale') +
    xlab('') +
    ylab('Estimate') +
    theme_bw() + 
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes")) +
    facet_wrap(~outcome)


a+b+c + plot_layout(ncol = 2, guides = "collect")

```


## Figure S6

```{r fig.height=3}
## Effect of candidate's indeological placement on fear

petro_left = lm_robust(fear_petro ~ petro_ideology 
                     +have_nots+size_population+urban+big_city+women+age
                     +education+catholic+religiosity+employed+married+color
                     +num_kids+sec_perception_neighborhood+victim_del
                     +stable_income+news_cons_d+trust_congress+nationalization
                     +interest_pol+media_exposure+political_machismo,
                        data = dt18, 
                        clusters = municipio)

petro_right = lm_robust(fear_petro ~ petro_ideology_r 
                     +have_nots+size_population+urban+big_city+women+age
                     +education+catholic+religiosity+employed+married+color
                     +num_kids+sec_perception_neighborhood+victim_del
                     +stable_income+news_cons_d+trust_congress+nationalization
                     +interest_pol+media_exposure+political_machismo,
                         data = dt18, 
                         clusters = municipio)


duque_left = lm_robust(fear_duque ~ duque_ideology_l 
                     +have_nots+size_population+urban+big_city+women+age
                     +education+catholic+religiosity+employed+married+color
                     +num_kids+sec_perception_neighborhood+victim_del
                     +stable_income+news_cons_d+trust_congress+nationalization
                     +interest_pol+media_exposure+political_machismo,
                        data = dt18, 
                        clusters = municipio)

id_placement = data.frame(outcome = c('Petro - Left',
                                      'Petro - Right',
                                      'Duque - Left'),
                          estimate = c(petro_left$coefficients[2], 
                                       petro_right$coefficients[2],
                                       duque_left$coefficients[2]),
                          lower = c(petro_left$conf.low[2],
                                    petro_right$conf.low[2],
                                    duque_left$conf.low[2]),
                          upper = c(petro_left$conf.high[2],
                                    petro_right$conf.high[2],
                                    duque_left$conf.high[2]))


ggplot(id_placement, aes(y=estimate, x=outcome)) +
        geom_point(position = pd) + 
        geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1) +
        geom_line(position = pd) +
        geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
        coord_flip() +
        ggtitle('Effect of Ideological Placement on Fear') +
        xlab('') +
        ylab('Estimate') +
        theme() + theme_bw() 

```


## Figure S7

```{r}

tax1.0 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22,
                   subset = ideology_r_3l_2r == 0,
                   clusters = ticket_id)


tax1.1 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22,
                   subset = ideology_r_3l_2r == 1,
                   clusters = ticket_id)

beta = tax1.0$coefficients[2]
lb = tax1.0$conf.low[2]
ub = tax1.0$conf.high[2]
dt_tax1.0 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Rightwing = 'No')


beta = tax1.1$coefficients[2]
lb = tax1.1$conf.low[2]
ub = tax1.1$conf.high[2]
dt_tax1.1 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Rightwing = 'Yes')


# Subsidies

Subsidies1.0 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22,
                         subset = ideology_r_3l_2r == 0,
                         clusters = ticket_id)

Subsidies1.1 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22,
                         subset = ideology_r_3l_2r == 1,
                         clusters = ticket_id)

beta = Subsidies1.0$coefficients[2]
lb = Subsidies1.0$conf.low[2]
ub = Subsidies1.0$conf.high[2]
dt_subsidy1.0 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Rightwing = 'No')


beta = Subsidies1.1$coefficients[2]
lb = Subsidies1.1$conf.low[2]
ub = Subsidies1.1$conf.high[2]
dt_subsidy1.1 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Rightwing = 'Yes')

dt1 = rbind(dt_tax1.0, dt_tax1.1,
            dt_subsidy1.0, dt_subsidy1.1) %>%
    mutate(variable = factor(variable, 
                             levels = c('Progressive Taxation','Subsidies')),
           ATE = rep('ATE', length(variable)))

## Study 2
tax2.0 = lm_robust(tax_dummy ~ t_tax,
                   data = col22_2,
                   subset = ideology_r_3l_2r == 0,
                   clusters = ticket_id)


tax2.1 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22_2,
                   subset = ideology_r_3l_2r == 1,
                   clusters = ticket_id)

beta = tax2.0$coefficients[2]
lb = tax2.0$conf.low[2]
ub = tax2.0$conf.high[2]
dt_tax2.0 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Rightwing = 'No')


beta = tax2.1$coefficients[2]
lb = tax2.1$conf.low[2]
ub = tax2.1$conf.high[2]
dt_tax2.1 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Rightwing = 'Yes')


# Subsidies

Subsidies2.0 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22_2,
                         subset = ideology_r_3l_2r == 0,
                         clusters = ticket_id)

Subsidies2.1 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22_2,
                         subset = ideology_r_3l_2r == 1,
                         clusters = ticket_id)

beta = Subsidies2.0$coefficients[2]
lb = Subsidies2.0$conf.low[2]
ub = Subsidies2.0$conf.high[2]
dt_subsidy2.0 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Rightwing = 'No')


beta = Subsidies2.1$coefficients[2]
lb = Subsidies2.1$conf.low[2]
ub = Subsidies2.1$conf.high[2]
dt_subsidy2.1 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Rightwing = 'Yes')

dt2 = rbind(dt_tax2.0, dt_tax2.1,
            dt_subsidy2.0, dt_subsidy2.1) %>%
    mutate(variable = factor(variable, 
                             levels = c('Progressive Taxation','Subsidies')),
           ATE = rep('ATE', length(variable)))


```

```{r fig.height=4}

# Plot
## Heterogeneous Preferences Among The Wealthy
preferences1 = ggplot(dt1,
                      aes(y=beta, x=ATE, ymin=lb, ymax=ub,
                          group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) +
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 1') +
    xlab('') +
    ylab('') +
    scale_y_continuous(limits = c(-.8,.8)) +
    coord_flip() +
    theme_bw() +
    theme(axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'none') +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable) +
    guides("none")

preferences2 = ggplot(dt2,
                      aes(y=beta, x=ATE, ymin=lb, ymax=ub,
                          group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) +
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 2') +
    xlab('') +
    ylab('Change in Pr(Support)') +
    scale_y_continuous(limits = c(-.8,.8)) +
    coord_flip() +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank(),
          legend.position = 'bottom') +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable)

preferences1 + preferences2 + plot_layout(ncol = 1)

```


## Figure S8

```{r}

# Mechanisms

## Uncertainty

uncert1.0 = lm_robust(uncert_scale ~ t_uncert, 
                      data = col22,
                      subset = ideology_r_3l_2r==0,
                      clusters = ticket_id)

uncert1.1 = lm_robust(uncert_scale ~ t_uncert, 
                      data = col22,
                      subset = ideology_r_3l_2r==1,
                      clusters = ticket_id)

beta = uncert1.0$coefficients[2]
lb = uncert1.0$conf.low[2]
ub = uncert1.0$conf.high[2]
dt_uncert1.0 = data.frame(variable = 'Uncertainty', beta, lb, ub, 
                          Rightwing = 'No')

beta = uncert1.1$coefficients[2]
lb = uncert1.1$conf.low[2]
ub = uncert1.1$conf.high[2]
dt_uncert1.1 = data.frame(variable = 'Uncertainty', beta, lb, ub, 
                          Rightwing = 'Yes')

dt_uncert1 = rbind(dt_uncert1.0, dt_uncert1.1)

## Effectiveness

eff1.0 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22,
                   subset = ideology_r_3l_2r == 0,
                   clusters = ticket_id)

eff1.1 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22,
                   subset = ideology_r_3l_2r == 1,
                   clusters = ticket_id)

beta = eff1.0$coefficients[2]
lb = eff1.0$conf.low[2]
ub = eff1.0$conf.high[2]
dt_eff1.0 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Rightwing = 'No')

beta = eff1.1$coefficients[2]
lb = eff1.1$conf.low[2]
ub = eff1.1$conf.high[2]
dt_eff1.1 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Rightwing = 'Yes')

## Economic Instability

stability1.0 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22,
                         subset = ideology_r_3l_2r == 0,
                         clusters = ticket_id)

stability1.1 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22,
                         subset = ideology_r_3l_2r == 1,
                         clusters = ticket_id)

beta = stability1.0$coefficients[2]
lb = stability1.0$conf.low[2]
ub = stability1.0$conf.high[2]
dt_stability1.0 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Rightwing = 'No')

beta = stability1.1$coefficients[2]
lb = stability1.1$conf.low[2]
ub = stability1.1$conf.high[2]
dt_stability1.1 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Rightwing = 'Yes')


dt1_mechanisms = rbind(dt_eff1.0, dt_eff1.1,
                       dt_stability1.0, dt_stability1.1) %>%
    mutate(ATE = rep('ATE', length(variable)))

## Study 2
uncert2.0 = lm_robust(uncert_scale ~ t_uncert,
                      data = col22_2,
                      subset = ideology_r_3l_2r==0,
                      clusters = ticket_id)

uncert2.1 = lm_robust(uncert_scale ~ t_uncert, 
                      data = col22_2,
                      subset = ideology_r_3l_2r==1,
                      clusters = ticket_id)

beta = uncert2.0$coefficients[2]
lb = uncert2.0$conf.low[2]
ub = uncert2.0$conf.high[2]
dt_uncert2.0 = data.frame(variable = 'Uncertainty', beta, lb, ub, Rightwing = 'No')

beta = uncert2.1$coefficients[2]
lb = uncert2.1$conf.low[2]
ub = uncert2.1$conf.high[2]
dt_uncert2.1 = data.frame(variable = 'Uncertainty', beta, lb, ub, Rightwing = 'Yes')

dt_uncert2 = rbind(dt_uncert2.0, dt_uncert2.1)

## Effectiveness

eff2.0 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22_2,
                   subset = ideology_r_3l_2r == 0,
                   clusters = ticket_id)

eff2.1 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22_2,
                   subset = ideology_r_3l_2r == 1,
                   clusters = ticket_id)

beta = eff2.0$coefficients[2]
lb = eff2.0$conf.low[2]
ub = eff2.0$conf.high[2]
dt_eff2.0 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Rightwing = 'No')

beta = eff2.1$coefficients[2]
lb = eff2.1$conf.low[2]
ub = eff2.1$conf.high[2]
dt_eff2.1 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Rightwing = 'Yes')

## Economic Instability

stability2.0 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22_2,
                         subset = ideology_r_3l_2r == 0,
                         clusters = ticket_id)

stability2.1 = lm_robust(stability_dummy ~ t_stability,
                         data = col22_2,
                         subset = ideology_r_3l_2r == 1,
                         clusters = ticket_id)

beta = stability2.0$coefficients[2]
lb = stability2.0$conf.low[2]
ub = stability2.0$conf.high[2]
dt_stability2.0 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Rightwing = 'No')

beta = stability2.1$coefficients[2]
lb = stability2.1$conf.low[2]
ub = stability2.1$conf.high[2]
dt_stability2.1 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Rightwing = 'Yes')


dt2_mechanisms = rbind(dt_eff2.0, dt_eff2.1,
                       dt_stability2.0, dt_stability2.1) %>%
    mutate(ATE = rep('ATE', length(variable)))


```

```{r fig.height=4}

## Heterogeneous Expectations Among The Wealthy
mechanisms1 = ggplot(dt1_mechanisms,
                     aes(y=beta, x=ATE, ymin=lb, ymax=ub,
                         group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) +
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 1') +
    xlab('') +
    ylab('') +
    scale_y_continuous(limits = c(-1,1)) +
    coord_flip() +
    theme_bw() +
    theme(axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'none') +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable) +
    guides("none")


mechanisms2 = ggplot(dt2_mechanisms,
                     aes(y=beta, x=ATE, ymin=lb, ymax=ub,
                         group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) +
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 2') +
    xlab('') +
    ylab('Change in Pr(Expectation)') +
    scale_y_continuous(limits = c(-1,1)) +
    coord_flip() +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank(),
          legend.position = 'bottom') +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable)

mechanisms1 + mechanisms2 + plot_layout(ncol = 1)



```


## Figure S9

```{r}
### ideology_3
tax1.0 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22,
                   subset = ideology_3 == -1,
                   clusters = ticket_id) 

tax1.1 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22,
                   subset = ideology_3 == 0,
                   clusters = ticket_id) 


tax1.2 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22,
                   subset = ideology_3 == 1,
                   clusters = ticket_id) 

beta = tax1.0$coefficients[2]
lb = tax1.0$conf.low[2]
ub = tax1.0$conf.high[2]
dt_tax1.0 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Ideology = 'L')

beta = tax1.1$coefficients[2]
lb = tax1.1$conf.low[2]
ub = tax1.1$conf.high[2]
dt_tax1.1 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Ideology = 'C')

beta = tax1.2$coefficients[2]
lb = tax1.2$conf.low[2]
ub = tax1.2$conf.high[2]
dt_tax1.2 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Ideology = 'R')


# Subsidies

Subsidies1.0 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22,
                         subset = ideology_3 == -1,
                         clusters = ticket_id) 

Subsidies1.1 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22,
                         subset = ideology_3 == 0,
                         clusters = ticket_id) 

Subsidies1.2 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22,
                         subset = ideology_3 == 1,
                         clusters = ticket_id) 

beta = Subsidies1.0$coefficients[2]
lb = Subsidies1.0$conf.low[2]
ub = Subsidies1.0$conf.high[2]
dt_subsidy1.0 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Ideology = 'L')

beta = Subsidies1.1$coefficients[2]
lb = Subsidies1.1$conf.low[2]
ub = Subsidies1.1$conf.high[2]
dt_subsidy1.1 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Ideology = 'C')

beta = Subsidies1.2$coefficients[2]
lb = Subsidies1.2$conf.low[2]
ub = Subsidies1.2$conf.high[2]
dt_subsidy1.2 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Ideology = 'R')

dt1 = rbind(dt_tax1.0, dt_tax1.1, dt_tax1.2, 
            dt_subsidy1.0, dt_subsidy1.1, dt_subsidy1.2) %>% 
    mutate(variable = factor(variable, levels = c('Progressive Taxation',
                                                  'Subsidies')),
           ATE = rep('ATE', length(variable)))

# Study 2
tax2.0 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22_2,
                   subset = ideology_3 == -1,
                   clusters = ticket_id) 

tax2.1 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22_2,
                   subset = ideology_3 == 0,
                   clusters = ticket_id) 


tax2.2 = lm_robust(tax_dummy ~ t_tax, 
                   data = col22_2,
                   subset = ideology_3 == 1,
                   clusters = ticket_id) 

beta = tax2.0$coefficients[2]
lb = tax2.0$conf.low[2]
ub = tax2.0$conf.high[2]
dt_tax2.0 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Ideology = 'L')

beta = tax2.1$coefficients[2]
lb = tax2.1$conf.low[2]
ub = tax2.1$conf.high[2]
dt_tax2.1 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Ideology = 'C')

beta = tax2.2$coefficients[2]
lb = tax2.2$conf.low[2]
ub = tax2.2$conf.high[2]
dt_tax2.2 = data.frame(variable = 'Progressive Taxation', beta, lb, ub, 
                       Ideology = 'R')


# Subsidies

Subsidies2.0 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22_2,
                         subset = ideology_3 == -1,
                         clusters = ticket_id) 

Subsidies2.1 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22_2,
                         subset = ideology_3 == 0,
                         clusters = ticket_id) 

Subsidies2.2 = lm_robust(subsidy_dummy ~ t_subsidy, 
                         data = col22_2,
                         subset = ideology_3 == 1,
                         clusters = ticket_id) 

beta = Subsidies2.0$coefficients[2]
lb = Subsidies2.0$conf.low[2]
ub = Subsidies2.0$conf.high[2]
dt_subsidy2.0 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Ideology = 'L')

beta = Subsidies2.1$coefficients[2]
lb = Subsidies2.1$conf.low[2]
ub = Subsidies2.1$conf.high[2]
dt_subsidy2.1 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Ideology = 'C')

beta = Subsidies2.2$coefficients[2]
lb = Subsidies2.2$conf.low[2]
ub = Subsidies2.2$conf.high[2]
dt_subsidy2.2 = data.frame(variable = 'Subsidies', beta, lb, ub, 
                           Ideology = 'R')

dt2 = rbind(dt_tax2.0, dt_tax2.1, dt_tax2.2, 
            dt_subsidy2.0, dt_subsidy2.1, dt_subsidy2.2) %>% 
    mutate(variable = factor(variable, 
                             levels = c('Progressive Taxation','Subsidies')),
           ATE = rep('ATE', length(variable)))

```

```{r fig.height=4}

# Plot
## Heterogeneous Preferences Among The Wealthy
preferences1 = ggplot(dt1, 
                      aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                          group=Ideology, color=Ideology)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 1') +
    xlab('') +
    ylab('') + 
    scale_y_continuous(limits = c(-.8,.8)) +
    coord_flip() + 
    theme_bw() +
    theme(axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'none') +
    scale_color_manual(values = c('#CCCCCC', '#999999','#333333'),
                       name="Respondents' Ideology", labels=c("C","L","R")) + 
    facet_wrap(~variable) +
    guides("none")

preferences2 = ggplot(dt2, 
                      aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                          group=Ideology, color=Ideology)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 2') +
    xlab('') +
    ylab('') + 
    scale_y_continuous(limits = c(-.8,.8)) +
    coord_flip() + 
    theme_bw() +
    theme(#axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'bottom') +
    scale_color_manual(values = c('#CCCCCC', '#999999','#333333'),
                       name="Respondents' Ideology", labels=c("C","L","R")) + 
    facet_wrap(~variable)

preferences1 + preferences2 + plot_layout(ncol = 1)


```


## Figure S10

```{r}

# Mechanisms 

## Uncertainty

uncert1.0 = lm_robust(uncert_scale ~ t_uncert, 
                      data = col22,
                      subset = ideology_3==-1,
                      clusters = ticket_id)

uncert1.1 = lm_robust(uncert_scale ~ t_uncert, 
                      data = col22,
                      subset = ideology_3==0,
                      clusters = ticket_id)

uncert1.2 = lm_robust(uncert_scale ~ t_uncert, 
                      data = col22,
                      subset = ideology_3==1,
                      clusters = ticket_id)

beta = uncert1.0$coefficients[2]
lb = uncert1.0$conf.low[2]
ub = uncert1.0$conf.high[2]
dt_uncert1.0 = data.frame(variable = 'Uncertainty', beta, lb, ub, Ideology = 'L')

beta = uncert1.1$coefficients[2]
lb = uncert1.1$conf.low[2]
ub = uncert1.1$conf.high[2]
dt_uncert1.1 = data.frame(variable = 'Uncertainty', beta, lb, ub, Ideology = 'C')

beta = uncert1.2$coefficients[2]
lb = uncert1.2$conf.low[2]
ub = uncert1.2$conf.high[2]
dt_uncert1.2 = data.frame(variable = 'Uncertainty', beta, lb, ub, Ideology = 'R')

dt_uncert1 = rbind(dt_uncert1.0, dt_uncert1.1, dt_uncert1.2)

## Effectiveness

eff1.0 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22,
                   subset = ideology_3 == -1,
                   clusters = ticket_id) 

eff1.1 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22,
                   subset = ideology_3 == 0,
                   clusters = ticket_id) 

eff1.2 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22,
                   subset = ideology_3 == 1,
                   clusters = ticket_id) 

beta = eff1.0$coefficients[2]
lb = eff1.0$conf.low[2]
ub = eff1.0$conf.high[2]
dt_eff1.0 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Ideology = 'L')

beta = eff1.1$coefficients[2]
lb = eff1.1$conf.low[2]
ub = eff1.1$conf.high[2]
dt_eff1.1 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Ideology = 'C')

beta = eff1.2$coefficients[2]
lb = eff1.2$conf.low[2]
ub = eff1.2$conf.high[2]
dt_eff1.2 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Ideology = 'R')

## Economic Instability

stability1.0 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22,
                         subset = ideology_3 == -1,
                         clusters = ticket_id)

stability1.1 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22,
                         subset = ideology_3 == 0,
                         clusters = ticket_id)

stability1.2 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22,
                         subset = ideology_3 == 1,
                         clusters = ticket_id)

beta = stability1.0$coefficients[2]
lb = stability1.0$conf.low[2]
ub = stability1.0$conf.high[2]
dt_stability1.0 = data.frame(variable = 'Instability', beta, lb, ub,
                             Ideology = 'L')

beta = stability1.1$coefficients[2]
lb = stability1.1$conf.low[2]
ub = stability1.1$conf.high[2]
dt_stability1.1 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Ideology = 'C')

beta = stability1.2$coefficients[2]
lb = stability1.2$conf.low[2]
ub = stability1.2$conf.high[2]
dt_stability1.2 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Ideology = 'R')

dt1_mechanisms = rbind(dt_eff1.0, dt_eff1.1, dt_eff1.2,
                       dt_stability1.0, dt_stability1.1, dt_stability1.2) %>% 
    mutate(ATE = rep('ATE', length(variable)))


# Study 2
uncert2.0 = lm_robust(uncert_scale ~ t_uncert, 
                      data = col22_2,
                      subset = ideology_3==-1,
                      clusters = ticket_id)

uncert2.1 = lm_robust(uncert_scale ~ t_uncert, 
                      data = col22_2,
                      subset = ideology_3==0,
                      clusters = ticket_id)

uncert2.2 = lm_robust(uncert_scale ~ t_uncert,
                      data = col22_2,
                      subset = ideology_3==1,
                      clusters = ticket_id)

beta = uncert2.0$coefficients[2]
lb = uncert2.0$conf.low[2]
ub = uncert2.0$conf.high[2]
dt_uncert2.0 = data.frame(variable = 'Uncertainty', beta, lb, ub, 
                          Ideology = 'L')

beta = uncert2.1$coefficients[2]
lb = uncert2.1$conf.low[2]
ub = uncert2.1$conf.high[2]
dt_uncert2.1 = data.frame(variable = 'Uncertainty', beta, lb, ub, 
                          Ideology = 'C')

beta = uncert2.2$coefficients[2]
lb = uncert2.2$conf.low[2]
ub = uncert2.2$conf.high[2]
dt_uncert2.2 = data.frame(variable = 'Uncertainty', beta, lb, ub, 
                          Ideology = 'R')

dt_uncert2 = rbind(dt_uncert2.0, dt_uncert2.1, dt_uncert2.2)

## Effectiveness

eff2.0 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22_2,
                   subset = ideology_3 == -1,
                   clusters = ticket_id) 

eff2.1 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22_2,
                   subset = ideology_3 == 0,
                   clusters = ticket_id) 

eff2.2 = lm_robust(effectiveness_dummy ~ t_effectiveness, 
                   data = col22_2,
                   subset = ideology_3 == 1,
                   clusters = ticket_id) 

beta = eff2.0$coefficients[2]
lb = eff2.0$conf.low[2]
ub = eff2.0$conf.high[2]
dt_eff2.0 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Ideology = 'L')

beta = eff2.1$coefficients[2]
lb = eff2.1$conf.low[2]
ub = eff2.1$conf.high[2]
dt_eff2.1 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Ideology = 'C')

beta = eff2.2$coefficients[2]
lb = eff2.2$conf.low[2]
ub = eff2.2$conf.high[2]
dt_eff2.2 = data.frame(variable = 'Efficiency', beta, lb, ub, 
                       Ideology = 'R')

## Economic Instability

stability2.0 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22_2,
                         subset = ideology_3 == -1,
                         clusters = ticket_id)

stability2.1 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22_2,
                         subset = ideology_3 == 0,
                         clusters = ticket_id)

stability2.2 = lm_robust(stability_dummy ~ t_stability, 
                         data = col22_2,
                         subset = ideology_3 == 1,
                         clusters = ticket_id)

beta = stability2.0$coefficients[2]
lb = stability2.0$conf.low[2]
ub = stability2.0$conf.high[2]
dt_stability2.0 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Ideology = 'L')

beta = stability2.1$coefficients[2]
lb = stability2.1$conf.low[2]
ub = stability2.1$conf.high[2]
dt_stability2.1 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Ideology = 'C')

beta = stability2.2$coefficients[2]
lb = stability2.2$conf.low[2]
ub = stability2.2$conf.high[2]
dt_stability2.2 = data.frame(variable = 'Instability', beta, lb, ub, 
                             Ideology = 'R')

dt2_mechanisms = rbind(dt_eff2.0, dt_eff2.1, dt_eff2.2,
                       dt_stability2.0, dt_stability2.1, dt_stability2.2) %>% 
    mutate(ATE = rep('ATE', length(variable)))

```

```{r fig.height=4}

## Heterogeneous Expectations Among The Wealthy
mechanisms1 = ggplot(dt1_mechanisms, 
                     aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                         group=Ideology, color=Ideology)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 1') +
    xlab('') +
    ylab('') + 
    scale_y_continuous(limits = c(-1,1)) +
    coord_flip() +
    theme_bw() +
    theme(axis.text.x = element_blank(), 
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'none') +
    scale_color_manual(values = c("#CCCCCC",'#999999','#333333'),
                       name="Respondents' Ideology", labels=c("C", "L","R")) +
    facet_wrap(~variable) +
    guides("none")

mechanisms2 = ggplot(dt2_mechanisms, 
                     aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                         group=Ideology, color=Ideology)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 2') +
    xlab('') +
    ylab('') + 
    scale_y_continuous(limits = c(-1,1)) +
    coord_flip() +
    theme_bw() +
    theme(#axis.text.x = element_blank(), 
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'bottom') +
    scale_color_manual(values = c("#CCCCCC",'#999999','#333333'),
                       name="Respondents' Ideology", labels=c("C", "L","R")) +
    facet_wrap(~variable)

mechanisms1 + mechanisms2 + plot_layout(ncol = 1)

```


## Figure S11

```{r fig.height=2}

## Regressions
out_s1 = list()
out_s1_1 = list()

covariates = c('+age','female','capital','white','catholic',
               'married','university_degree','employed','exp_crime',
               'guerrilla_threat','migration','trust_institutions',
               'ideology_r_mean2','resent','vote_fico')

for(i in 1:length(f)){
    out_s1[[i]] = lm_robust(as.formula(paste(f[i], 
                                             paste(covariates, collapse = '+'))), 
                            data = col22_subset, clusters = ticket_id)
    out_s1_1[[i]] = lm_robust(f[[i]], data = col22_subset, clusters = ticket_id)
}

outcomes_s1_subset = data.frame(outcome = c('Progressive Taxation',
                                     'Subsidies',
                                     'Uncertainty',
                                     'Efficiency',
                                     'Stability',
                                     'Police',
                                     'Visa',
                                     'Progressive Taxation',
                                     'Subsidies',
                                     'Uncertainty',
                                     'Efficiency',
                                     'Stability',
                                     'Police',
                                     'Visa'),
                         ATE = c(rep('ATE', length(f)*2)),
                         estimate = c(foreach(i=1:length(f)) %do% 
                                          out_s1[[i]]$coefficients[2] %>% 
                                          unlist(), foreach(i=1:length(f)) %do% 
                                          out_s1_1[[i]]$coefficients[2] %>% 
                                          unlist()),
                         lower = c(foreach(i=1:length(f)) %do% 
                                       out_s1[[i]]$conf.low[2] %>% 
                                       unlist(), foreach(i=1:length(f)) %do% 
                                       out_s1_1[[i]]$conf.low[2] %>% 
                                       unlist()),
                         upper = c(foreach(i=1:length(f)) %do% 
                                       out_s1[[i]]$conf.high[2] %>% 
                                       unlist(), foreach(i=1:length(f)) %do% 
                                       out_s1_1[[i]]$conf.high[2] %>% 
                                       unlist()),
                         group = c('Preferences','Preferences',
                                   'Explanations','Explanations','Explanations',
                                   'Placebos','Placebos'),
                         covariates = c(rep(1, length(f)),
                                        rep(0, length(f))))

## preferences plot
outcomes_s1_subset %>% 
    filter(group=='Preferences') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('Redistributive Preferences - Study 1') +
    xlab('') +
    ylab('Change in Pr(Support)') +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes"),
                       guide = guide_legend(reverse = TRUE)) +
    facet_wrap(~outcome)

```


## Figure S12

```{r fig.height=2}
out_s2 = list()
out_s2_1 = list()
covariates2 = c('+age','female','capital','white','catholic',
                'married','university_degree',
                'employed','exp_crime',
                'guerrilla_threat','migration','trust_institutions',
                'ideology_r_mean2','resent','rodolf_right','vote_hernandez')

for(i in 1:length(f)){
    out_s2[[i]] = lm_robust(as.formula(paste(f[i], 
                                             paste(covariates2, collapse = '+'))), 
                            data = col22_2_subset, clusters = ticket_id)
    out_s2_1[[i]] = lm_robust(f[[i]], data = col22_2_subset, clusters = ticket_id)
}

outcomes_s2_subset = data.frame(outcome = c('Progressive Taxation',
                                     'Subsidies',
                                     'Uncertainty',
                                     'Efficiency',
                                     'Stability',
                                     'Police',
                                     'Visa',
                                     'Progressive Taxation',
                                     'Subsidies',
                                     'Uncertainty',
                                     'Efficiency',
                                     'Stability',
                                     'Police',
                                     'Visa'),
                         ATE = c(rep('ATE', length(f)*2)),
                         estimate = c(foreach(i=1:length(f)) %do% 
                                          out_s2[[i]]$coefficients[2] %>% 
                                          unlist(), foreach(i=1:length(f)) %do% 
                                          out_s2_1[[i]]$coefficients[2] %>% 
                                          unlist()),
                         lower = c(foreach(i=1:length(f)) %do% 
                                       out_s2[[i]]$conf.low[2] %>% 
                                       unlist(), foreach(i=1:length(f)) %do% 
                                       out_s2_1[[i]]$conf.low[2] %>% 
                                       unlist()),
                         upper = c(foreach(i=1:length(f)) %do% 
                                       out_s2[[i]]$conf.high[2] %>% 
                                       unlist(), foreach(i=1:length(f)) %do% 
                                       out_s2_1[[i]]$conf.high[2] %>% 
                                       unlist()),
                         group = c('Preferences','Preferences',
                                   'Explanations','Explanations','Explanations',
                                   'Placebos','Placebos'),
                         covariates = c(rep(1, length(f)),
                                        rep(0, length(f))))

outcomes_s2_subset %>% 
    filter(group=='Preferences') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    ggtitle('Redistributive Preferences - Study 2') +
    xlab('') +
    ylab('Change in Pr(Support)') +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes"),
                       guide = guide_legend(reverse = TRUE)) +
    facet_wrap(~outcome)

```


## Figure S13

```{r fig.height=4}

placebos_s1 = outcomes_s1 %>% 
    filter(group=='Placebos') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    labs(subtitle = 'Study 1') +
    xlab('') +
    ylab('') +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes"),
                       guide = guide_legend(reverse = TRUE)) +
    facet_wrap(~outcome)

placebos_s2 = outcomes_s2 %>% 
    filter(group=='Placebos') %>% 
    ggplot(., aes(y=estimate, x=ATE, color=as.factor(covariates))) +
    geom_point(position = pd) + 
    geom_errorbar(aes(ymin=lower, ymax=upper), width=0.1, position = pd) +
    geom_line(position = pd) +
    geom_hline(yintercept = 0, color = "grey", linetype = "dashed") +
    coord_flip() +
    labs(subtitle = 'Study 2') +
    xlab('') +
    ylab('Change in Pr(Support)') +
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank()) + 
    scale_color_manual(values = c('#999999','#333333'),
                       name="Covariates", labels=c("No","Yes"),
                       guide = guide_legend(reverse = TRUE)) +
    facet_wrap(~outcome)


placebos_s1 + placebos_s2 + plot_layout(ncol = 1, guides = 'collect')

```


## Figure S14

```{r fig.height=4}
# Migration
mig1.0 = lm_robust(visa_dummy ~ t_visa,
                   data = col22,
                   subset = ideology_r_mean == 0,
                   clusters = ticket_id)

mig1.1 = lm_robust(visa_dummy ~ t_visa,
                   data = col22,
                   subset = ideology_r_mean == 1,
                   clusters = ticket_id)

beta = mig1.0$coefficients[2]
lb = mig1.0$conf.low[2]
ub = mig1.0$conf.high[2]
dt_mig1.0 = data.frame(variable = 'Visas', beta, lb, ub, Rightwing = 'No')

beta = mig1.1$coefficients[2]
lb = mig1.1$conf.low[2]
ub = mig1.1$conf.high[2]
dt_mig1.1 = data.frame(variable = 'Visas', beta, lb, ub, Rightwing = 'Yes')

# Police
police1.0 = lm_robust(police_dummy ~ t_police,
                      data = col22,
                      subset = ideology_r_mean == 0,
                      clusters = ticket_id)

police1.1 = lm_robust(police_dummy ~ t_police,
                      data = col22,
                      subset = ideology_r_mean == 1,
                      clusters = ticket_id)


beta = police1.0$coefficients[2]
lb = police1.0$conf.low[2]
ub = police1.0$conf.high[2]
dt_police1.0 = data.frame(variable = 'Police', beta, lb, ub, Rightwing = 'No')


beta = police1.1$coefficients[2]
lb = police1.1$conf.low[2]
ub = police1.1$conf.high[2]
dt_police1.1 = data.frame(variable = 'Police', beta, lb, ub, Rightwing = 'Yes')


# Migration
mig2.0 = lm_robust(visa_dummy ~ t_visa,
                   data = col22_2,
                   subset = ideology_r_mean == 0,
                   clusters = ticket_id)

mig2.1 = lm_robust(visa_dummy ~ t_visa,
                   data = col22_2,
                   subset = ideology_r_mean == 1,
                   clusters = ticket_id)

beta = mig2.0$coefficients[2]
lb = mig2.0$conf.low[2]
ub = mig2.0$conf.high[2]
dt_mig2.0 = data.frame(variable = 'Visas', beta, lb, ub, Rightwing = 'No')

beta = mig2.1$coefficients[2]
lb = mig2.1$conf.low[2]
ub = mig2.1$conf.high[2]
dt_mig2.1 = data.frame(variable = 'Visas', beta, lb, ub, Rightwing = 'Yes')

# Police
police2.0 = lm_robust(police_dummy ~ t_police,
                      data = col22_2,
                      subset = ideology_r_mean == 0,
                      clusters = ticket_id)

police2.1 = lm_robust(police_dummy ~ t_police,
                      data = col22_2,
                      subset = ideology_r_mean == 1,
                      clusters = ticket_id)


beta = police2.0$coefficients[2]
lb = police2.0$conf.low[2]
ub = police2.0$conf.high[2]
dt_police2.0 = data.frame(variable = 'Police', beta, lb, ub, Rightwing = 'No')


beta = police2.1$coefficients[2]
lb = police2.1$conf.low[2]
ub = police2.1$conf.high[2]
dt_police2.1 = data.frame(variable = 'Police', beta, lb, ub, Rightwing = 'Yes')


## Plots
dt1_placebos = rbind(dt_police1.0, dt_police1.1,dt_mig1.0, dt_mig1.1) %>%
    mutate(variable = factor(variable, levels = c('Police','Visas')),
           ATE = rep('ATE', length(variable)))

dt1_placebos_plot = ggplot(dt1_placebos, 
                           aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                               group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 1') +
    xlab('') +
    ylab('') + 
    #scale_y_continuous(limits = c(-.8,.8)) +
    coord_flip() + 
    theme_bw() +
    theme(axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          legend.position = 'none') +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable) +
    guides("none")


dt2_placebos = rbind(dt_police2.0, dt_police2.1,dt_mig2.0, dt_mig2.1) %>%
    mutate(variable = factor(variable, levels = c('Police','Visas')),
           ATE = rep('ATE', length(variable)))

dt2_placebos_plot = ggplot(dt2_placebos, 
                           aes(y=beta, x=ATE, ymin=lb, ymax=ub, 
                               group=Rightwing, color=Rightwing)) +
    geom_point(position = position_dodge(w=0.3)) +
    geom_linerange(key_glyph ='path', position = position_dodge(w=0.3)) + 
    geom_hline(yintercept = 0, colour = 'black', linetype = 'dashed') +
    labs(subtitle =  'Study 2') +
    xlab('') +
    ylab('Change in Pr(Support)') + 
    #scale_y_continuous(limits = c(-.8,.8)) +
    coord_flip() + 
    theme_bw() +
    theme(axis.text.y = element_blank(),
          axis.ticks.y = element_blank(),
          legend.position = 'bottom') +
    scale_color_manual(values = c('#999999','#333333'),
                       name="Respondents' Ideology", labels=c("L","R")) +
    facet_wrap(~variable)

dt1_placebos_plot + dt2_placebos_plot + plot_layout(ncol = 1)

```


# Online SI - Tables

## Table S1

```{r}
col22_covariates = col22
col22_covariates = col22_covariates %>% 
    mutate(across(c(age,white,catholic,married,university_degree,
                    employed,trust_institutions,resent), as.numeric),
           female=as.character(female) %>% as.numeric(),
           capital=as.character(capital) %>% as.numeric(),
           right_ideology=as.character(ideology_r_mean2) %>% as.numeric()) %>% 
    as.data.table

variables = c('age','female','capital','white','catholic',
              'married','university_degree',
              'employed','right_ideology')


equiv_taxes <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_covariates[t_tax==0]
    dt_1 = col22_covariates[t_tax==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}


equiv_subsidy <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_covariates[t_subsidy==0]
    dt_1 = col22_covariates[t_subsidy==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}


equiv_uncert <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_covariates[t_uncert==0]
    dt_1 = col22_covariates[t_uncert==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}

equiv_eff <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_covariates[t_effectiveness==0]
    dt_1 = col22_covariates[t_effectiveness==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}

equiv_stability <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_covariates[t_stability==0]
    dt_1 = col22_covariates[t_stability==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}


equivalence_dt1 = rbindlist(list(equiv_taxes, equiv_subsidy,
                                 equiv_uncert, equiv_eff, equiv_stability))

# Generate latex table 
kbl(equivalence_dt1, 'latex',
    caption = 'Equivalence Table (Study 1) - T0 vs T1',
    col.names =  c("Variable","Mean Difference",
                   "CI (+/-)",
                   "p-val"), position = 'h', align = 'c',
    longtable = T) %>% 
    pack_rows(group_label = 'Progressive Taxation', 1,9) %>% 
    pack_rows(group_label = 'Subsidies', 10,18) %>% 
    pack_rows(group_label = 'Uncertainty', 19,27) %>% 
    pack_rows(group_label = 'Efficiency', 28,35) %>% 
    pack_rows(group_label = 'Instability', 36,43) 

```


## Table S2

```{r}
col22_2_covariates = col22_2
col22_2_covariates = col22_2_covariates %>% 
    mutate(across(c(age,white,catholic,married,university_degree,
                    employed,trust_institutions,resent), as.numeric),
           female=as.character(female) %>% as.numeric(),
           capital=as.character(capital) %>% as.numeric(),
           right_ideology=as.character(ideology_r_mean2) %>% as.numeric()) %>% 
    as.data.table

variables = c('age','female','capital','white','catholic',
              'married','university_degree',
              'employed','right_ideology')

equiv_taxes2 <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_2_covariates[t_tax==0]
    dt_1 = col22_2_covariates[t_tax==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}

equiv_subsidy2 <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_2_covariates[t_subsidy==0]
    dt_1 = col22_2_covariates[t_subsidy==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}

equiv_uncert2 <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_2_covariates[t_uncert==0]
    dt_1 = col22_2_covariates[t_uncert==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}

equiv_eff2 <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_2_covariates[t_effectiveness==0]
    dt_1 = col22_2_covariates[t_effectiveness==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}

equiv_stability2 <- foreach(i = 1:length(variables), .combine = 'rbind') %do% 
  {
    dt_0 = col22_2_covariates[t_stability==0]
    dt_1 = col22_2_covariates[t_stability==1]
    variable = variables[i] 
    # Observed mean difference
    diff_mean = (mean(dt_0[[variable]], na.rm = T) - 
                   mean(dt_1[[variable]], na.rm = T)) %>% 
        round(., 3)
    # Equivalence analysis
    eqv = equivtest::equiv.t.test(x = dt_0[[variable]], y = dt_1[[variable]],
                                  eps_tol = 'strict')
    eqv_ci = eqv$CI_sub[2] %>% round(., 3)
    eqv_p = eqv$p %>% round(., 3)
    # return
    out = data.frame(Variable=variables[i], diff_mean,eqv_ci,eqv_p)
    return(out)
}

equivalence_dt2 = rbindlist(list(equiv_taxes2, equiv_subsidy2,
                                 equiv_uncert2, equiv_eff2, equiv_stability2))

# Generate latex table 
kbl(equivalence_dt2, 'latex',
    caption = 'Equivalence Table (Study 2) - T0 vs T1',
    col.names =  c("Variable","Mean Difference",
                   "CI (+/-)",
                   "p-val"), position = 'h', align = 'c',
    longtable = T) %>% 
    pack_rows(group_label = 'Progressive Taxation', 1,9) %>% 
    pack_rows(group_label = 'Subsidies', 10,18) %>% 
    pack_rows(group_label = 'Uncertainty', 19,27) %>% 
    pack_rows(group_label = 'Efficiency', 28,35) %>% 
    pack_rows(group_label = 'Instability', 36,43)  

```


## Table S3

```{r results='asis'}

out_s1 = list()
out_s1_1 = list()

f = list(tax_dummy~t_tax,
         subsidy_dummy~t_subsidy,
         uncert_scale~t_uncert,
         effectiveness_dummy~t_effectiveness,
         stability_dummy~t_stability)

covariates = c('+age','female','capital','white','catholic',
               'married','university_degree',
               'employed','exp_crime','guerrilla_threat',
               'migration','trust_institutions',
               'ideology_r_mean2',
               'resent','vote_fico')

for(i in 1:length(f)){
    out_s1[[i]] = lm_robust(as.formula(paste(f[i],
                                             paste(covariates, collapse = '+'))),
                            data = col22)
    out_s1_1[[i]] = lm_robust(f[[i]], data = col22)
}


# harmonizing coefficients
out_s1_1[[1]]$term[2] = 't1'
out_s1_1[[2]]$term[2] = 't1'
out_s1_1[[3]]$term[2] = 't1'
out_s1_1[[4]]$term[2] = 't1'
out_s1_1[[5]]$term[2] = 't1'


# with covariate
out_s1[[1]]$term[2] = 't1'
out_s1[[2]]$term[2] = 't1'
out_s1[[3]]$term[2] = 't1'
out_s1[[4]]$term[2] = 't1'
out_s1[[5]]$term[2] = 't1'


```

```{r results='asis'}


# regression table
texreg(list(out_s1_1[[1]], out_s1_1[[2]], 
            out_s1_1[[3]], out_s1_1[[4]], out_s1_1[[5]]),
       use.packages = FALSE,
       caption = "Regression Results - Study 1 (without covariates)",
       label = "table:results_s1_baseline",
       custom.model.names = c('Pro. Tax.','Subsidies',
                              "Uncertainty","Efficiency","Instability"),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                                 't1'='T1 = Rightwing Candidate'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=F,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F, include.nclust=F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. Robust standard errors."
)



```


## Table S4

```{r results='asis'}


texreg(list(out_s1[[1]], out_s1[[2]], 
            out_s1[[3]], out_s1[[4]], out_s1[[5]]),
       caption = "Regression Results - Study 1 (with covariates)",
       use.packages = FALSE,
       label = "table:results_s1",
       custom.model.names = c('Pro. Tax.','Subsidies',
                              "Uncertainty","Efficiency","Instability"),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate',
                              'age2'='Age(25-34)',
                              'age3'='Age(35-44)',
                              'age4'='Age(45-54)',
                              'age5'='Age(55+)',
                              'female1'='Female',
                              'capital1'='Capital',
                              'white'='White',
                              'catholic'='Catholic',
                              'married'='Married',
                              'university_degree'='Education',
                              'employed'='Employed',
                              'exp_crime1'='Exp. crime',
                              'guerrilla_threat1'='Guerrilla threat',
                              'migration1'='Int. to migrate',
                              'trust_institutions'='Trust inst.',
                              'ideology_r_mean2'='Ideology (Right)',
                              'resent'='Percep. of resent.',
                              'vote_fico1'='Vote (Right)'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=T,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F, include.nclust=F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. Robust standard errors."
)
```


## Table S5

```{r}

out_s2 = list()
out_s2_1 = list()
covariates2 = c('+age','female','capital','white','catholic',
                'married','university_degree',
               'employed','exp_crime','guerrilla_threat',
               'migration','trust_institutions',
               'ideology_r_mean2','resent',
               'rodolf_right','vote_hernandez')

for(i in 1:length(f)){
    out_s2[[i]] = lm_robust(as.formula(paste(f[i], 
                                             paste(covariates2, collapse = '+'))), 
                            data = col22_2)
    out_s2_1[[i]] = lm_robust(f[[i]], data = col22_2)
}

out_s2_1[[1]]$term[2] = 't1'
out_s2_1[[2]]$term[2] = 't1'
out_s2_1[[3]]$term[2] = 't1'
out_s2_1[[4]]$term[2] = 't1'
out_s2_1[[5]]$term[2] = 't1'


out_s2[[1]]$term[2] = 't1'
out_s2[[2]]$term[2] = 't1'
out_s2[[3]]$term[2] = 't1'
out_s2[[4]]$term[2] = 't1'
out_s2[[5]]$term[2] = 't1'


```

```{r results='asis'}

texreg(list(out_s2_1[[1]], out_s2_1[[2]], 
            out_s2_1[[3]], out_s2_1[[4]], out_s2_1[[5]]),
       use.packages = FALSE,
       caption = "Regression Results - Study 2 (without covariates)",
       label = "table:results_s2_baseline",
       custom.model.names = c('Pro. Tax.','Subsidies',
                              "Uncertainty","Efficiency","Instability"),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=F,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F, include.nclust=F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. Robust standard errors."
)

```


## Table S6

```{r results='asis'}

texreg(list(out_s2[[1]], out_s2[[2]], 
            out_s2[[3]], out_s2[[4]], out_s2[[5]]),
       caption = "Regression Results - Study 2 (with covariates)",
       use.packages = FALSE,
       label = "table:results_s2",
       custom.model.names = c('Pro. Tax.','Subsidies',
                              "Uncertainty","Efficiency","Instability"),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate',
                              'age2'='Age(25-34)',
                              'age3'='Age(35-44)',
                              'age4'='Age(45-54)',
                              'age5'='Age(55+)',
                              'female1'='Female',
                              'capital1'='Capital',
                              'white'='White',
                              'catholic'='Catholic',
                              'married'='Married',
                              'university_degree'='Education',
                              'employed'='Employed',
                              'exp_crime1'='Exp. crime',
                              'guerrilla_threat1'='Guerrilla threat',
                              'migration1'='Int. to migrate',
                              'trust_institutions'='Trust inst.',
                              'resent'='Percep. of resent.',
                              'ideology_r_mean2'='Ideology (Right)',
                              'rodolf_right'='Hernández Id.',
                              'vote_hernandez1'='Vote (Right)'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=T,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F, include.nclust=F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. Robust standard errors."
)

```


## Table S7

```{r results='asis'}

f3 = 'uncert_scale3~t_uncert'

uncertainty_out_s1 = list()
uncertainty_out_s1_1 = list()
uncertainty_out_s2 = list()
uncertainty_out_s2_1 = list()

covariates = c('+age','female','capital','white','catholic',
               'married','university_degree',
               'employed','exp_crime','guerrilla_threat',
               'migration','trust_institutions',
               'ideology_r_mean2','resent',
               'vote_fico')

covariates2 = c('+age','female','capital','white','catholic',
                'married','university_degree',
                'employed','exp_crime','guerrilla_threat',
                'migration','trust_institutions',
                'ideology_r_mean2','resent',
                'rodolf_right','vote_hernandez')


for(i in 1:length(f3)){
    uncertainty_out_s1[[i]] = lm_robust(as.formula(paste(f3, 
                                                         paste(covariates, 
                                                               collapse = '+'))), 
                            data = col22)
    uncertainty_out_s1_1[[i]] = lm_robust(as.formula(f3), data = col22)
}

for(i in 1:length(f3)){
    uncertainty_out_s2[[i]] = lm_robust(as.formula(paste(f3, 
                                                         paste(covariates2, 
                                                               collapse = '+'))), 
                            data = col22_2)
    uncertainty_out_s2_1[[i]] = lm_robust(as.formula(f3), data = col22_2)
}


# mechanisms table
texreg(list(uncertainty_out_s1_1[[1]], uncertainty_out_s1[[1]],
               uncertainty_out_s2_1[[1]], uncertainty_out_s2[[1]]),
       caption = "Effect on Uncertainty (Alternative coding)",
       label = "table:uncertainty",
       use.packages = FALSE,
       custom.header = list('Study 1'=1:2,
                            'Study 2'=3:4),
       custom.model.names = c('1','2','3','4'),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't_uncert1'='T1 = Rightwing Candidate'),
       float.pos = "H",
       digits = 3,
       caption.above = TRUE,
       #custom.coef.names = mechanisms1_controls,
       include.rsquared = F, include.adjrs = F, include.groups = T,
       include.ci = F, include.nclust=F,
       custom.gof.rows = list("Covariate Adjustment"=c("No","Yes",
                                                       "No","Yes")),
       #reorder.gof = c(1,3,4,2,5,6),
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)


```


## Table S8

```{r results='asis'}

trust_subsidy = lm_robust(rodolf_trust~t_subsidy, data = col22_2) 
trust_tax = lm_robust(rodolf_trust~t_tax, data = col22_2) 

trust_subsidy_controls = lm_robust(as.formula(paste('rodolf_trust~t_subsidy', 
                                                    paste(covariates2, 
                                                          collapse='+'))), 
                                   data = col22_2) 
trust_tax_controls = lm_robust(as.formula(paste('rodolf_trust~t_tax', 
                                                paste(covariates2, 
                                                      collapse='+'))), 
                               data = col22_2) 

# regression table
texreg(list(trust_tax,trust_tax_controls,
            trust_subsidy,trust_subsidy_controls),
       use.packages = FALSE,
       caption = "Effect of Redistributive Proposal on Trust",
       label = "table:trust_proposal",
       custom.model.names = c('1','2','3','4'),
       custom.coef.map = list('(Intercept)'='(Intercept)',
                              't_tax1'='Tax (T1)',
                              't_subsidy1'='Subsidy (T1)'),
       float.pos = "H",
       digits = 3,
       caption.above = TRUE,
       #custom.coef.names = mechanisms1_controls,
       include.rsquared = F, include.adjrs = F, include.groups = T,
       include.ci = F, include.nclust=F,
       custom.gof.rows = list("Covariate Adjustment"=c("No","Yes",
                                                       "No","Yes")),
       #reorder.gof = c(1,3,4,2,5,6),
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)


```


## Table S9

```{r}

f_complete = list(tax_dummy~t_tax,
                  subsidy_dummy~t_subsidy,
                  uncert_scale~t_uncert,
                  effectiveness_dummy~t_effectiveness,
                  stability_dummy~t_stability,
                  police_dummy~t_police,
                  visa_dummy~t_visa)


outcomes = c('Progressive Taxation',
             'Subsidies','Uncertainty',
             'Efficiency','Instability',
             'Police','Visa')

for(i in 1:length(f_complete)){
    out_s1_1[[i]] = lm_robust(f_complete[[i]], data = col22)
}

unadjusted = p.adjust(foreach(i=1:length(f_complete)) %do% 
                        out_s1_1[[i]]$p.value[2] %>% 
                          unlist(), method = 'none', n=7) %>% round(., 3)

fdr = p.adjust(foreach(i=1:length(f_complete)) %do% 
                 out_s1_1[[i]]$p.value[2] %>% 
                   unlist(), method = 'fdr', n=7) %>% round(., 3)

pval = data.frame(Estimate = foreach(i=1:length(f_complete)) %do% 
                    out_s1_1[[i]]$coefficients[2] %>% 
                      unlist(),
                  Unadjusted = unadjusted,
                  FDR = fdr)

rownames(pval) = outcomes

kbl(pval, 'latex',
          caption = 'Adjusted p-values - Study 1',
          position = 'H', align = 'c', label = 'adjusted_pval')
```


## Table S10

```{r}

out_s2_1 = list()


for(i in 1:length(f_complete)){
    out_s2_1[[i]] = lm_robust(f_complete[[i]], data = col22_2)
}

unadjusted2 = p.adjust(foreach(i=1:length(f_complete)) %do% 
                         out_s2_1[[i]]$p.value[2] %>% 
                           unlist(), method = 'none', n=7) %>% round(., 3)

fdr2 = p.adjust(foreach(i=1:length(f_complete)) %do% 
                  out_s2_1[[i]]$p.value[2] %>% 
                    unlist(), method = 'fdr', n=7) %>% round(., 3)

pval2 = data.frame(Estimate = foreach(i=1:length(f_complete)) %do% 
                     out_s2_1[[i]]$coefficients[2] %>% 
                       unlist(),
                   Unadjusted = unadjusted2,
                   FDR = fdr2)

rownames(pval2) = outcomes

kbl(pval2, 'latex',
          caption = 'Adjusted p-values - Study 2',
          position = 'H', align = 'c', label = 'adjusted_pval_s2')

```


## Table S11

```{r}

tax.out = lm_robust(tax_dummy ~ t_tax*ideology_r_mean, data = col22) 
subsidy.out = lm_robust(subsidy_dummy ~ t_subsidy*ideology_r_mean, data = col22) 
uncert.out = lm_robust(uncert_scale ~ t_uncert*ideology_r_mean, data = col22)
eff.out = lm_robust(effectiveness_dummy ~ t_effectiveness*ideology_r_mean, data=col22)
stability.out = lm_robust(stability_dummy ~ t_stability*ideology_r_mean, data = col22) 
# harmonizing coefficients
tax.out$term[2]='t1'
subsidy.out$term[2]='t1'
uncert.out$term[2]='t1'
eff.out$term[2]='t1'
stability.out$term[2]='t1'

tax.out$term[4]='t1:ideology_r_mean'
subsidy.out$term[4]='t1:ideology_r_mean'
uncert.out$term[4]='t1:ideology_r_mean'
eff.out$term[4]='t1:ideology_r_mean'
stability.out$term[4]='t1:ideology_r_mean'
```


```{r results='asis'}

texreg(list(tax.out, subsidy.out, 
            uncert.out, eff.out, stability.out),
       caption = "Heterogeneous Effects (Ideology  = Right) - Study 1",
       use.packages = FALSE,
       label = "table:heterogeneity_ideology_s1",
       custom.model.names = c('Pro. Tax.','Subsidies',
                              "Uncertainty","Efficiency","Instability"),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate',
                              't1:ideology_r_mean'='T1 X Ideology (Right)',
                               'ideology_r_mean'='Ideology (Right)'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=T,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F, include.nclust=F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)

```


## Table S12

```{r}

tax.out2 = lm_robust(tax_dummy ~ t_tax*ideology_r_mean, data = col22_2) 
subsidy.out2 = lm_robust(subsidy_dummy ~ t_subsidy*ideology_r_mean, data = col22_2) 
uncert.out2 = lm_robust(uncert_scale ~ t_uncert*ideology_r_mean, data = col22_2)
eff.out2 = lm_robust(effectiveness_dummy ~ t_effectiveness*ideology_r_mean, data = col22_2) 
stability.out2 = lm_robust(stability_dummy ~ t_stability*ideology_r_mean, data = col22_2) 

tax.out2$term[2]='t1'
subsidy.out2$term[2]='t1'
uncert.out2$term[2]='t1'
eff.out2$term[2]='t1'
stability.out2$term[2]='t1'

tax.out2$term[4]='t1:ideology_r_mean'
subsidy.out2$term[4]='t1:ideology_r_mean'
uncert.out2$term[4]='t1:ideology_r_mean'
eff.out2$term[4]='t1:ideology_r_mean'
stability.out2$term[4]='t1:ideology_r_mean'

```


```{r results='asis'}

texreg(list(tax.out2, subsidy.out2, 
            uncert.out2, eff.out2, stability.out2),
       caption = "Heterogeneous Effects (Ideology = Right) - Study 2",
       use.packages = FALSE,
       label = "table:heterogeneity_ideology_s2",
       custom.model.names = c('Pro. Tax.','Subsidies',
                              "Uncertainty","Efficiency","Instability"),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate',
                              't1:ideology_r_mean'='T1 X Ideology (Right)',
                               'ideology_r_mean'='Ideology (Right)'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=T,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F, include.nclust=F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)



```


## Table S13

```{r}

tax.out.id = lm_robust(tax_dummy ~ t_tax*vote_fico, data = col22) 
subsidy.out.id = lm_robust(subsidy_dummy ~ t_subsidy*vote_fico, data = col22) 
uncert.out.id = lm_robust(uncert_scale ~ t_uncert*vote_fico, data = col22)
eff.out.id = lm_robust(effectiveness_dummy ~ t_effectiveness*vote_fico, data = col22) 
stability.out.id = lm_robust(stability_dummy ~ t_stability*vote_fico, data = col22) 

tax.out.id$term[2]='t1'
subsidy.out.id$term[2]='t1'
uncert.out.id$term[2]='t1'
eff.out.id$term[2]='t1'
stability.out.id$term[2]='t1'

tax.out.id$term[4]='t1:vote_fico1'
subsidy.out.id$term[4]='t1:vote_fico1'
uncert.out.id$term[4]='t1:vote_fico1'
eff.out.id$term[4]='t1:vote_fico1'
stability.out.id$term[4]='t1:vote_fico1'

```

```{r results='asis'}

texreg(list(tax.out.id, subsidy.out.id, 
            uncert.out.id, eff.out.id, stability.out.id),
       caption = "Heterogeneous Effects (Vote Intention = Right-wing) - Study 1",
       use.packages = FALSE,
       label = "table:heterogeneity_vote_s1",
       custom.model.names = c('Pro. Tax.','Subsidies',
                              "Uncertainty","Efficiency","Instability"),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate',
                              't1:vote_fico1'='T1 X  Vote (Right)',
                              'vote_fico1'='Vote (Right)'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=T,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F, include.nclust=F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)

```


## Table S14

```{r}
tax.out.id2 = lm_robust(tax_dummy ~ t_tax*vote_hernandez, data = col22_2) 
subsidy.out.id2 = lm_robust(subsidy_dummy ~ t_subsidy*vote_hernandez, data = col22_2) 
uncert.out.id2 = lm_robust(uncert_scale ~ t_uncert*vote_hernandez, data = col22_2)
eff.out.id2 = lm_robust(effectiveness_dummy ~ t_effectiveness*vote_hernandez, data = col22_2) 
stability.out.id2 = lm_robust(stability_dummy ~ t_stability*vote_hernandez, data = col22_2) 

tax.out.id2$term[2]='t1'
subsidy.out.id2$term[2]='t1'
uncert.out.id2$term[2]='t1'
eff.out.id2$term[2]='t1'
stability.out.id2$term[2]='t1'

tax.out.id2$term[4]='t1:vote_hernandez1'
subsidy.out.id2$term[4]='t1:vote_hernandez1'
uncert.out.id2$term[4]='t1:vote_hernandez1'
eff.out.id2$term[4]='t1:vote_hernandez1'
stability.out.id2$term[4]='t1:vote_hernandez1'
```


```{r results='asis'}

texreg(list(tax.out.id2,subsidy.out.id2,
            uncert.out.id2,eff.out.id2,stability.out.id2),
       caption = "Heterogeneous Effects (Vote Intention = Right-wing) - Study 2",
       use.packages = FALSE,
       label = "table:heterogeneity_vote_s2",
       custom.model.names = c('Pro. Tax.','Subsidies',
                              "Uncertainty","Efficiency","Instability"),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate',
                              't1:vote_hernandez1'='T1 X  Vote (Right)',
                               'vote_hernandez1'='Vote (Right)'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=T,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F, include.nclust=F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)

```


## Table S15

```{r}
out_s1 = list()
out_s1_1 = list()

covariates = c('+age','female','capital','white','catholic',
               'married','university_degree',
               'employed','exp_crime','guerrilla_threat','migration',
               'trust_institutions',
               'ideology_r_mean','resent','vote_fico')

for(i in 1:length(f)){
    out_s1[[i]] = lm_robust(as.formula(paste(f[i], paste(covariates, 
                                                         collapse = '+'))), 
                            data = col22_subset, clusters = ticket_id)
    out_s1_1[[i]] = lm_robust(f[[i]], data = col22_subset, clusters = ticket_id)
}

# harmonizing coefficients
out_s1_1[[3]]$term[2] = 't1'
out_s1_1[[4]]$term[2] = 't1'
out_s1_1[[5]]$term[2] = 't1'

out_s1[[3]]$term[2] = 't1'
out_s1[[4]]$term[2] = 't1'
out_s1[[5]]$term[2] = 't1'
```

```{r results='asis'}


texreg(list(out_s1_1[[3]], out_s1[[3]], 
            out_s1_1[[4]], out_s1[[4]], 
            out_s1_1[[5]], out_s1[[5]]),
       caption = "Testing Theoretical Explanations in Subgroup - Study 1",
       label = "table:mechanisms1_subgroup",
       use.packages = FALSE,
       custom.header = list('Uncertainty'=1:2,
                            'Efficiency'=3:4,
                            'Instability'=5:6),
       custom.model.names = c('1','2','3','4','5','6'),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate'),
       float.pos = "H",
       digits = 3,
       caption.above = TRUE,
       #custom.coef.names = mechanisms1_controls,
       include.rsquared = F, include.adjrs = F, include.groups = T,
       include.ci = F, include.nclust=F,
       custom.gof.rows = list("Covariate Adjustment"=c("No","Yes",
                                                       "No","Yes",
                                                       "No","Yes")),
       #reorder.gof = c(1,3,4,2,5,6),
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)


```


## Table S16

```{r}
out_s2 = list()
out_s2_1 = list()
covariates2 = c('+age','female','capital','white','catholic',
                'married','university_degree',
                'employed','exp_crime','guerrilla_threat','migration',
                'trust_institutions',
                'ideology_r_mean','resent','rodolf_right','vote_hernandez')

for(i in 1:length(f)){
    out_s2[[i]] = lm_robust(as.formula(paste(f[i], paste(covariates2, 
                                                         collapse = '+'))), 
                            data = col22_2_subset, clusters = ticket_id)
    out_s2_1[[i]] = lm_robust(f[[i]], data = col22_2_subset, clusters = ticket_id)
}


# harmonizing coefficients
out_s2_1[[3]]$term[2] = 't1'
out_s2_1[[4]]$term[2] = 't1'
out_s2_1[[5]]$term[2] = 't1'

out_s2[[3]]$term[2] = 't1'
out_s2[[4]]$term[2] = 't1'
out_s2[[5]]$term[2] = 't1'
```

```{r results='asis'}

texreg(list(out_s2_1[[3]], out_s2[[3]], 
            out_s2_1[[4]], out_s2[[4]], 
            out_s2_1[[5]], out_s2[[5]]),
       caption = "Testing Theoretical Explanations in Subgroup - Study 2",
       use.packages = FALSE,
       label = "table:mechanisms2_subgroup",
       custom.header = list('Uncertainty'=1:2,
                            'Efficiency'=3:4,
                            'Instability'=5:6),
       custom.model.names = c('1','2','3','4','5','6'),
       custom.coef.map = list('(Intercept)'='Base category\\\\(T0 = Leftwing Candidate)',
                              't1'='T1 = Rightwing Candidate'),
       float.pos = "H",
       digits = 3,
       caption.above = TRUE,
       #custom.coef.names = mechanisms1_controls,
       include.rsquared = F, include.adjrs = F, include.groups = T,
       include.ci = F, include.nclust=F,
       custom.gof.rows = list("Covariate Adjustment"=c("No","Yes",
                                                       "No","Yes",
                                                       "No","Yes")),
       #reorder.gof = c(1,3,4,2,5,6),
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. OLS models with robust standard errors."
)

```


## Table S17

```{r}
petro_left <- lm_robust(fear_petro ~ petro_ideology 
                        +have_nots+size_population+urban+big_city+women+age
                        +education+catholic+religiosity
                        +employed+married+color+num_kids
                        +sec_perception_neighborhood+victim_del
                        +stable_income+news_cons_d
                        +trust_congress+nationalization
                        +interest_pol+media_exposure+political_machismo,
                        data = dt18, 
                        clusters = municipio)

petro_right <- lm_robust(fear_petro ~ petro_ideology_r 
                         + have_nots+size_population+urban+big_city+women+age
                         +education+catholic+religiosity
                         +employed+married+color+num_kids
                         +sec_perception_neighborhood+victim_del
                         +stable_income+news_cons_d
                         +trust_congress+nationalization
                         +interest_pol+media_exposure+political_machismo,
                         data = dt18, 
                         clusters = municipio)


duque_left <- lm_robust(fear_duque ~ duque_ideology_l                       
                         +have_nots+size_population+urban+big_city+women+age
                         +education+catholic+religiosity
                         +employed+married+color+num_kids
                         +sec_perception_neighborhood+victim_del
                         +stable_income+news_cons_d
                         +trust_congress+nationalization
                         +interest_pol+media_exposure+political_machismo,

                        data = dt18, 
                        clusters = municipio)

```

```{r results='asis'}

texreg(list(petro_left,petro_right,duque_left),
       use.packages = FALSE,
       caption = "Regression Results - Left-Wing Candidate",
       label = "table:petro_analyses",
       custom.model.names = c('Fear of Petro', 'Fear of Petro', 'Fear of Duque'),
       custom.coef.map = list('(Intercept)'='(Intercept)',
                              'petro_ideology1'='Petro Left',
                              'petro_ideology_r1'='Petro Right',
                              'duque_ideology_l1'='Duque Left',
                              'have_nots'='Low income',
                              'stable_income'='Stable income',
                              'size_population'='Pop. size',
                              'urban'='Urban',
                              'big_city'='Big city',
                              'women'='Female',
                              'age'='Age',
                              'education'='Education',
                              'catholic'='Catholic',
                              'religiosity'='Religiosity',
                              'employed'='Employed',
                              'married'='Married',
                              'color'='Race',
                              'num_kids'='Num. kids',
                              'sec_perception_neighborhood'='Sec. perception',
                              'victim_del'='Victim del.',
                              'news_cons_d'='Media consumption',
                              'media_exposure'='Media exposure',
                              'trust_congress'='Trust Cong.',
                              'nationalization'='Ideology',
                              'interest_pol'='Interest in pol.',
                              'political_machismo'='Machismo'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=T,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.note = "\\item%stars. Standard errors clustered at the municipal level."
)

```


## Table S18

```{r}

out = lm_robust(progressive_redist ~ consumpd*right_gov_dummy +
                        size_population+urban+big_city+women+age+education+
                        catholic+sec_perception_neighborhood+religiosity+
                        employed+married+color+news_cons_d+victim_del+
                        stable_income+trust_congress+trust_parties+
                        trust_president+gov_assistance+stable_cnt_econ+ 
                        stable_ind_econ+voted_pdt, 
                data = dt, 
                clusters = municipio, fixed_effects = country) 

# without country FE
out2 = lm_robust(progressive_redist ~ consumpd*right_gov_dummy +
                        size_population+urban+big_city+women+age+education+
                        catholic+sec_perception_neighborhood+religiosity+
                        employed+married+color+news_cons_d+victim_del+
                        stable_income+trust_congress+trust_parties+
                        trust_president+gov_assistance+stable_cnt_econ+ 
                        stable_ind_econ+voted_pdt, 
                data = dt, 
                clusters = municipio) 
```

```{r results='asis'}
texreg(list(out,out2),
       caption = 'Regression Results - Cross-country Analyses',
       use.packages = FALSE,
       label = "table:countries",
       #custom.model.names = 'Support for Redistribution',
       custom.coef.map = list('consumpd2'='Decile 2',
                              'consumpd3'='Decile 3',
                              'consumpd4'='Decile 4',
                              'consumpd5'='Decile 5',
                              'consumpd6'='Decile 6',
                              'consumpd7'='Decile 7',
                              'consumpd8'='Decile 8',
                              'consumpd9'='Decile 9',
                              'consumpd10'='Decile 10',
                              'size_population'='Pop. size',
                              'urban'='Urban',
                              'big_city'='Big city',
                              'women'='Female',
                              'age'='Age',
                              'education'='Education',
                              'catholic'='Catholic',
                              'sec_perception_neighborhood'='Sec. perception',
                              'religiosity'='Religiosity',
                              'employed'='Employed',
                              'married'='Married',
                              'color'='Race',
                              'news_cons_d'='Media consumption',
                              'victim_del'='Victim del.',
                              'stable_income'='Stable income',
                              'trust_congress'='Trust Cong.',
                              'trust_parties'='Trust parties',
                              'trust_president'='Trust president',
                              'gov_assistance'='Gov. assistance',
                              'stable_cnt_econ'='Stable cnt econ',
                              'stable_ind_econ'='Stable ind econ',
                              'voted_pdt'='Voted',
                              'consumpd2:right_gov_dummy1'='Decile 2 X Right',
                              'consumpd3:right_gov_dummy1'='Decile 3 X Right',
                              'consumpd4:right_gov_dummy1'='Decile 4 X Right',
                              'consumpd5:right_gov_dummy1'='Decile 5 X Right',
                              'consumpd6:right_gov_dummy1'='Decile 6 X Right',
                              'consumpd7:right_gov_dummy1'='Decile 7 X Right',
                              'consumpd8:right_gov_dummy1'='Decile 8 X Right',
                              'consumpd9:right_gov_dummy1'='Decile 9 X Right',
                              'consumpd10:right_gov_dummy1'='Decile 10 X Right'),
       float.pos = "H",
       digits = 3,
       caption.above = T,
       longtable=T,
       booktabs = T,
       include.rsquared = T, include.adjrs = T, include.groups = T,
       include.ci = F,
       threeparttable = TRUE,
       stars = c(0.01, 0.05, 0.1),
       custom.gof.rows = list("Country FE"=c("Yes","No")),
       custom.note = "\\item%stars. Standard errors clustered at the municipal level."
)

```



















